id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
16,300 | vespolina/VespolinaCommerceBundle | Resolver/AbstractFulfillmentMethodResolver.php | AbstractFulfillmentMethodResolver.getFulfillmentMethodsByType | protected function getFulfillmentMethodsByType($type)
{
if (!$this->fulfillmentMethodsByType) {
$this->loadFulfillmentMethods();
}
return $this->fulfillmentMethodsByType->get($type);
} | php | protected function getFulfillmentMethodsByType($type)
{
if (!$this->fulfillmentMethodsByType) {
$this->loadFulfillmentMethods();
}
return $this->fulfillmentMethodsByType->get($type);
} | [
"protected",
"function",
"getFulfillmentMethodsByType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fulfillmentMethodsByType",
")",
"{",
"$",
"this",
"->",
"loadFulfillmentMethods",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fulfillmentMethodsByType",
"->",
"get",
"(",
"$",
"type",
")",
";",
"}"
]
| Retrieve a collection of fulfillment methods by type
eg. give back all fulfillment methods for type 'shipment'
@param $type
@return ArrayCollection | [
"Retrieve",
"a",
"collection",
"of",
"fulfillment",
"methods",
"by",
"type",
"eg",
".",
"give",
"back",
"all",
"fulfillment",
"methods",
"for",
"type",
"shipment"
]
| 0644dd2c0fb39637a0a6c2838b02e17bc480bdbc | https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Resolver/AbstractFulfillmentMethodResolver.php#L37-L44 |
16,301 | vespolina/VespolinaCommerceBundle | Resolver/AbstractFulfillmentMethodResolver.php | AbstractFulfillmentMethodResolver.loadFulfillmentMethods | protected function loadFulfillmentMethods()
{
$this->fulfillmentMethodsByType = new ArrayCollection();
foreach ($this->configuration as $type => $configurationFulfillmentMethods) {
foreach ($configurationFulfillmentMethods as $configurationFulfillmentMethod) {
if (array_key_exists('class', $configurationFulfillmentMethod)) {
$class = $configurationFulfillmentMethod['class'];
$fulfillmentMethod = new $class();
$fulfillmentMethodsInType = $this->fulfillmentMethodsByType->get($type);
if (!$fulfillmentMethodsInType) {
$fulfillmentMethodsInType = new ArrayCollection();
$this->fulfillmentMethodsByType->set($type, $fulfillmentMethodsInType);
}
$fulfillmentMethodsInType->add($fulfillmentMethod);
}
}
}
} | php | protected function loadFulfillmentMethods()
{
$this->fulfillmentMethodsByType = new ArrayCollection();
foreach ($this->configuration as $type => $configurationFulfillmentMethods) {
foreach ($configurationFulfillmentMethods as $configurationFulfillmentMethod) {
if (array_key_exists('class', $configurationFulfillmentMethod)) {
$class = $configurationFulfillmentMethod['class'];
$fulfillmentMethod = new $class();
$fulfillmentMethodsInType = $this->fulfillmentMethodsByType->get($type);
if (!$fulfillmentMethodsInType) {
$fulfillmentMethodsInType = new ArrayCollection();
$this->fulfillmentMethodsByType->set($type, $fulfillmentMethodsInType);
}
$fulfillmentMethodsInType->add($fulfillmentMethod);
}
}
}
} | [
"protected",
"function",
"loadFulfillmentMethods",
"(",
")",
"{",
"$",
"this",
"->",
"fulfillmentMethodsByType",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"configuration",
"as",
"$",
"type",
"=>",
"$",
"configurationFulfillmentMethods",
")",
"{",
"foreach",
"(",
"$",
"configurationFulfillmentMethods",
"as",
"$",
"configurationFulfillmentMethod",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'class'",
",",
"$",
"configurationFulfillmentMethod",
")",
")",
"{",
"$",
"class",
"=",
"$",
"configurationFulfillmentMethod",
"[",
"'class'",
"]",
";",
"$",
"fulfillmentMethod",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"fulfillmentMethodsInType",
"=",
"$",
"this",
"->",
"fulfillmentMethodsByType",
"->",
"get",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"fulfillmentMethodsInType",
")",
"{",
"$",
"fulfillmentMethodsInType",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"$",
"this",
"->",
"fulfillmentMethodsByType",
"->",
"set",
"(",
"$",
"type",
",",
"$",
"fulfillmentMethodsInType",
")",
";",
"}",
"$",
"fulfillmentMethodsInType",
"->",
"add",
"(",
"$",
"fulfillmentMethod",
")",
";",
"}",
"}",
"}",
"}"
]
| Load fulfillment methods from the configuration | [
"Load",
"fulfillment",
"methods",
"from",
"the",
"configuration"
]
| 0644dd2c0fb39637a0a6c2838b02e17bc480bdbc | https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Resolver/AbstractFulfillmentMethodResolver.php#L49-L70 |
16,302 | keiosweb/moneyright | src/Money.php | Money.unserialize | public function unserialize($serialized)
{
$unserialized = unserialize($serialized);
$this->amount = $unserialized['amount'];
$this->currency = unserialize($unserialized['currency']);
} | php | public function unserialize($serialized)
{
$unserialized = unserialize($serialized);
$this->amount = $unserialized['amount'];
$this->currency = unserialize($unserialized['currency']);
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"$",
"unserialized",
"=",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"$",
"this",
"->",
"amount",
"=",
"$",
"unserialized",
"[",
"'amount'",
"]",
";",
"$",
"this",
"->",
"currency",
"=",
"unserialize",
"(",
"$",
"unserialized",
"[",
"'currency'",
"]",
")",
";",
"}"
]
| Unserializing Money value object
@param string $serialized | [
"Unserializing",
"Money",
"value",
"object"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Money.php#L126-L132 |
16,303 | keiosweb/moneyright | src/Money.php | Money.multiply | public function multiply($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
{
$this->assertOperand($operand);
$validatedOperand = $this->normalizeOperand($operand);
if ($useGaapPrecision) {
$amount = Math::bcround(
bcmul($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::GAAP_PRECISION,
$roundingMode
);
} else {
$amount = Math::bcround(
bcmul($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::BASIC_PRECISION,
$roundingMode
);
}
return new Money($amount, $this->currency);
} | php | public function multiply($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
{
$this->assertOperand($operand);
$validatedOperand = $this->normalizeOperand($operand);
if ($useGaapPrecision) {
$amount = Math::bcround(
bcmul($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::GAAP_PRECISION,
$roundingMode
);
} else {
$amount = Math::bcround(
bcmul($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::BASIC_PRECISION,
$roundingMode
);
}
return new Money($amount, $this->currency);
} | [
"public",
"function",
"multiply",
"(",
"$",
"operand",
",",
"$",
"roundingMode",
"=",
"self",
"::",
"ROUND_HALF_UP",
",",
"$",
"useGaapPrecision",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"assertOperand",
"(",
"$",
"operand",
")",
";",
"$",
"validatedOperand",
"=",
"$",
"this",
"->",
"normalizeOperand",
"(",
"$",
"operand",
")",
";",
"if",
"(",
"$",
"useGaapPrecision",
")",
"{",
"$",
"amount",
"=",
"Math",
"::",
"bcround",
"(",
"bcmul",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"validatedOperand",
",",
"self",
"::",
"GAAP_PRECISION",
"+",
"1",
")",
",",
"self",
"::",
"GAAP_PRECISION",
",",
"$",
"roundingMode",
")",
";",
"}",
"else",
"{",
"$",
"amount",
"=",
"Math",
"::",
"bcround",
"(",
"bcmul",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"validatedOperand",
",",
"self",
"::",
"GAAP_PRECISION",
"+",
"1",
")",
",",
"self",
"::",
"BASIC_PRECISION",
",",
"$",
"roundingMode",
")",
";",
"}",
"return",
"new",
"Money",
"(",
"$",
"amount",
",",
"$",
"this",
"->",
"currency",
")",
";",
"}"
]
| Multiplying compatible with Verraes' Money
To use GAAP precision rounding, pass true as third argument
@param $operand
@param int $roundingMode
@param bool $useGaapPrecision
@return \Keios\MoneyRight\Money
@throws \Keios\MoneyRight\Exceptions\InvalidArgumentException | [
"Multiplying",
"compatible",
"with",
"Verraes",
"Money",
"To",
"use",
"GAAP",
"precision",
"rounding",
"pass",
"true",
"as",
"third",
"argument"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Money.php#L310-L331 |
16,304 | keiosweb/moneyright | src/Money.php | Money.divide | public function divide($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
{
$this->assertOperand($operand, true);
$validatedOperand = $this->normalizeOperand($operand);
if ($useGaapPrecision) {
$amount = Math::bcround(
bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::GAAP_PRECISION,
$roundingMode
);
} else {
$amount = Math::bcround(
bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::BASIC_PRECISION,
$roundingMode
);
}
return new Money($amount, $this->currency);
} | php | public function divide($operand, $roundingMode = self::ROUND_HALF_UP, $useGaapPrecision = false)
{
$this->assertOperand($operand, true);
$validatedOperand = $this->normalizeOperand($operand);
if ($useGaapPrecision) {
$amount = Math::bcround(
bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::GAAP_PRECISION,
$roundingMode
);
} else {
$amount = Math::bcround(
bcdiv($this->amount, $validatedOperand, self::GAAP_PRECISION + 1),
self::BASIC_PRECISION,
$roundingMode
);
}
return new Money($amount, $this->currency);
} | [
"public",
"function",
"divide",
"(",
"$",
"operand",
",",
"$",
"roundingMode",
"=",
"self",
"::",
"ROUND_HALF_UP",
",",
"$",
"useGaapPrecision",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"assertOperand",
"(",
"$",
"operand",
",",
"true",
")",
";",
"$",
"validatedOperand",
"=",
"$",
"this",
"->",
"normalizeOperand",
"(",
"$",
"operand",
")",
";",
"if",
"(",
"$",
"useGaapPrecision",
")",
"{",
"$",
"amount",
"=",
"Math",
"::",
"bcround",
"(",
"bcdiv",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"validatedOperand",
",",
"self",
"::",
"GAAP_PRECISION",
"+",
"1",
")",
",",
"self",
"::",
"GAAP_PRECISION",
",",
"$",
"roundingMode",
")",
";",
"}",
"else",
"{",
"$",
"amount",
"=",
"Math",
"::",
"bcround",
"(",
"bcdiv",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"validatedOperand",
",",
"self",
"::",
"GAAP_PRECISION",
"+",
"1",
")",
",",
"self",
"::",
"BASIC_PRECISION",
",",
"$",
"roundingMode",
")",
";",
"}",
"return",
"new",
"Money",
"(",
"$",
"amount",
",",
"$",
"this",
"->",
"currency",
")",
";",
"}"
]
| Division compatible with Verraes' Money
To use GAAP precision rounding, pass true as third argument
@param $operand
@param int $roundingMode
@param bool $useGaapPrecision
@return \Keios\MoneyRight\Money
@throws \Keios\MoneyRight\Exceptions\InvalidArgumentException | [
"Division",
"compatible",
"with",
"Verraes",
"Money",
"To",
"use",
"GAAP",
"precision",
"rounding",
"pass",
"true",
"as",
"third",
"argument"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Money.php#L344-L365 |
16,305 | keiosweb/moneyright | src/Money.php | Money.allocate | public function allocate(array $ratios, $useGaapPrecision = false)
{
$useGaapPrecision ? $precision = self::GAAP_PRECISION : $precision = self::BASIC_PRECISION;
$remainder = $this->amount;
$results = [];
$total = array_sum($ratios);
foreach ($ratios as $ratio) {
$share = bcdiv(
bcmul(
$this->amount,
(string)$ratio,
$precision
),
(string)$total,
$precision
);
$results[] = new Money($share, $this->currency);
$remainder = bcsub($remainder, $share, $precision);
}
$count = count($results) - 1;
$index = 0;
$minValue = '0.'.str_repeat('0', $precision - 1).'1';
while (bccomp($remainder, '0'.str_repeat('0', $precision), $precision) !== 0) {
$remainder = bcsub($remainder, $minValue, $precision);
$results[$index] = $results[$index]->add(new Money($minValue, $this->currency));
if ($index !== $count) {
$index++;
} else {
$index = 0;
}
}
return $results;
} | php | public function allocate(array $ratios, $useGaapPrecision = false)
{
$useGaapPrecision ? $precision = self::GAAP_PRECISION : $precision = self::BASIC_PRECISION;
$remainder = $this->amount;
$results = [];
$total = array_sum($ratios);
foreach ($ratios as $ratio) {
$share = bcdiv(
bcmul(
$this->amount,
(string)$ratio,
$precision
),
(string)$total,
$precision
);
$results[] = new Money($share, $this->currency);
$remainder = bcsub($remainder, $share, $precision);
}
$count = count($results) - 1;
$index = 0;
$minValue = '0.'.str_repeat('0', $precision - 1).'1';
while (bccomp($remainder, '0'.str_repeat('0', $precision), $precision) !== 0) {
$remainder = bcsub($remainder, $minValue, $precision);
$results[$index] = $results[$index]->add(new Money($minValue, $this->currency));
if ($index !== $count) {
$index++;
} else {
$index = 0;
}
}
return $results;
} | [
"public",
"function",
"allocate",
"(",
"array",
"$",
"ratios",
",",
"$",
"useGaapPrecision",
"=",
"false",
")",
"{",
"$",
"useGaapPrecision",
"?",
"$",
"precision",
"=",
"self",
"::",
"GAAP_PRECISION",
":",
"$",
"precision",
"=",
"self",
"::",
"BASIC_PRECISION",
";",
"$",
"remainder",
"=",
"$",
"this",
"->",
"amount",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"total",
"=",
"array_sum",
"(",
"$",
"ratios",
")",
";",
"foreach",
"(",
"$",
"ratios",
"as",
"$",
"ratio",
")",
"{",
"$",
"share",
"=",
"bcdiv",
"(",
"bcmul",
"(",
"$",
"this",
"->",
"amount",
",",
"(",
"string",
")",
"$",
"ratio",
",",
"$",
"precision",
")",
",",
"(",
"string",
")",
"$",
"total",
",",
"$",
"precision",
")",
";",
"$",
"results",
"[",
"]",
"=",
"new",
"Money",
"(",
"$",
"share",
",",
"$",
"this",
"->",
"currency",
")",
";",
"$",
"remainder",
"=",
"bcsub",
"(",
"$",
"remainder",
",",
"$",
"share",
",",
"$",
"precision",
")",
";",
"}",
"$",
"count",
"=",
"count",
"(",
"$",
"results",
")",
"-",
"1",
";",
"$",
"index",
"=",
"0",
";",
"$",
"minValue",
"=",
"'0.'",
".",
"str_repeat",
"(",
"'0'",
",",
"$",
"precision",
"-",
"1",
")",
".",
"'1'",
";",
"while",
"(",
"bccomp",
"(",
"$",
"remainder",
",",
"'0'",
".",
"str_repeat",
"(",
"'0'",
",",
"$",
"precision",
")",
",",
"$",
"precision",
")",
"!==",
"0",
")",
"{",
"$",
"remainder",
"=",
"bcsub",
"(",
"$",
"remainder",
",",
"$",
"minValue",
",",
"$",
"precision",
")",
";",
"$",
"results",
"[",
"$",
"index",
"]",
"=",
"$",
"results",
"[",
"$",
"index",
"]",
"->",
"add",
"(",
"new",
"Money",
"(",
"$",
"minValue",
",",
"$",
"this",
"->",
"currency",
")",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"$",
"count",
")",
"{",
"$",
"index",
"++",
";",
"}",
"else",
"{",
"$",
"index",
"=",
"0",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
]
| Allocate the money according to a list of ratio's
Allocation is compatible with Verraes' Money
To use GAAP precision rounding, pass true as second argument
@param array $ratios List of ratio's
@param bool $useGaapPrecision
@return array | [
"Allocate",
"the",
"money",
"according",
"to",
"a",
"list",
"of",
"ratio",
"s",
"Allocation",
"is",
"compatible",
"with",
"Verraes",
"Money",
"To",
"use",
"GAAP",
"precision",
"rounding",
"pass",
"true",
"as",
"second",
"argument"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Money.php#L377-L414 |
16,306 | syhol/mrcolor | src/SyHolloway/MrColor/Color.php | Color.bulkUpdate | public function bulkUpdate($values)
{
foreach ($values as $property => $value) {
$this->update($property, $value);
}
return $this;
} | php | public function bulkUpdate($values)
{
foreach ($values as $property => $value) {
$this->update($property, $value);
}
return $this;
} | [
"public",
"function",
"bulkUpdate",
"(",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"update",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Updates the object with multiple values
Key value pairs in an array of properties and values, i.e.
array(
'red' => 22,
'green => 44
)
@param array $values
@return object self | [
"Updates",
"the",
"object",
"with",
"multiple",
"values"
]
| b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d | https://github.com/syhol/mrcolor/blob/b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d/src/SyHolloway/MrColor/Color.php#L111-L118 |
16,307 | syhol/mrcolor | src/SyHolloway/MrColor/Color.php | Color.update | public function update($using = 'hex', $value = false)
{
if ('hex' == $using || 'alpha' == $using) {
$this->$using = $value;
}
$this->hex = $this->formats->update($using, $value, $this->hex);
return $this;
} | php | public function update($using = 'hex', $value = false)
{
if ('hex' == $using || 'alpha' == $using) {
$this->$using = $value;
}
$this->hex = $this->formats->update($using, $value, $this->hex);
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"using",
"=",
"'hex'",
",",
"$",
"value",
"=",
"false",
")",
"{",
"if",
"(",
"'hex'",
"==",
"$",
"using",
"||",
"'alpha'",
"==",
"$",
"using",
")",
"{",
"$",
"this",
"->",
"$",
"using",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"hex",
"=",
"$",
"this",
"->",
"formats",
"->",
"update",
"(",
"$",
"using",
",",
"$",
"value",
",",
"$",
"this",
"->",
"hex",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Updates the object with a value
The property to update is set with the $using var
the new value of the property specified is set with the $value var
this method syncs all color properties based on the values passed
@param string $using
@param string $value
@return object self | [
"Updates",
"the",
"object",
"with",
"a",
"value"
]
| b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d | https://github.com/syhol/mrcolor/blob/b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d/src/SyHolloway/MrColor/Color.php#L132-L141 |
16,308 | piqus/bfp4f-rcon | src/T4G/BFP4F/Rcon/Server.php | Server.fetch | public function fetch()
{
$data = Base::query('bf2cc si');
$spl = explode("\t", $data);
$result = array
(
'name' => $spl[7],
'map' => $spl[5],
'playersCurrent' => $spl[3],
'playersMax' => $spl[2],
'playersJoining' => $spl[4],
'tickets' => array($spl[10] - $spl[11], $spl[10] - $spl[16]),
'ticketsMax' => $spl[10],
'timeElapsed' => $spl[18],
'timeRemaining' => $spl[19]
);
return (object) $result;
} | php | public function fetch()
{
$data = Base::query('bf2cc si');
$spl = explode("\t", $data);
$result = array
(
'name' => $spl[7],
'map' => $spl[5],
'playersCurrent' => $spl[3],
'playersMax' => $spl[2],
'playersJoining' => $spl[4],
'tickets' => array($spl[10] - $spl[11], $spl[10] - $spl[16]),
'ticketsMax' => $spl[10],
'timeElapsed' => $spl[18],
'timeRemaining' => $spl[19]
);
return (object) $result;
} | [
"public",
"function",
"fetch",
"(",
")",
"{",
"$",
"data",
"=",
"Base",
"::",
"query",
"(",
"'bf2cc si'",
")",
";",
"$",
"spl",
"=",
"explode",
"(",
"\"\\t\"",
",",
"$",
"data",
")",
";",
"$",
"result",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"spl",
"[",
"7",
"]",
",",
"'map'",
"=>",
"$",
"spl",
"[",
"5",
"]",
",",
"'playersCurrent'",
"=>",
"$",
"spl",
"[",
"3",
"]",
",",
"'playersMax'",
"=>",
"$",
"spl",
"[",
"2",
"]",
",",
"'playersJoining'",
"=>",
"$",
"spl",
"[",
"4",
"]",
",",
"'tickets'",
"=>",
"array",
"(",
"$",
"spl",
"[",
"10",
"]",
"-",
"$",
"spl",
"[",
"11",
"]",
",",
"$",
"spl",
"[",
"10",
"]",
"-",
"$",
"spl",
"[",
"16",
"]",
")",
",",
"'ticketsMax'",
"=>",
"$",
"spl",
"[",
"10",
"]",
",",
"'timeElapsed'",
"=>",
"$",
"spl",
"[",
"18",
"]",
",",
"'timeRemaining'",
"=>",
"$",
"spl",
"[",
"19",
"]",
")",
";",
"return",
"(",
"object",
")",
"$",
"result",
";",
"}"
]
| Fetches Server Info
@return object | [
"Fetches",
"Server",
"Info"
]
| 8e94587bc93c686e5a025a54645aed7c701811e6 | https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Server.php#L26-L46 |
16,309 | drpdigital/json-api-parser | src/JsonApiValidator.php | JsonApiValidator.validator | public function validator($type, $validator)
{
$this->validators[$type] = $validator;
$this->resolver($type, function ($data, $resourceId) use ($type) {
/** @var \Drp\JsonApiParser\Contracts\ValidatorExecutor[] $validators */
$validators = Arr::wrap($this->validators[$type]);
foreach ($validators as $validator) {
$data['id'] = $resourceId;
$validator->with($data);
$result = $validator->passes();
if (!$result) {
$errors = $validator->errors();
$types = explode('.', $type);
$key = end($types);
if ($resourceId !== null) {
$key .= '_' . $resourceId;
}
$this->errors[$key] = array_merge(Arr::get($this->errors, $key, []), $errors);
}
}
});
return $this;
} | php | public function validator($type, $validator)
{
$this->validators[$type] = $validator;
$this->resolver($type, function ($data, $resourceId) use ($type) {
/** @var \Drp\JsonApiParser\Contracts\ValidatorExecutor[] $validators */
$validators = Arr::wrap($this->validators[$type]);
foreach ($validators as $validator) {
$data['id'] = $resourceId;
$validator->with($data);
$result = $validator->passes();
if (!$result) {
$errors = $validator->errors();
$types = explode('.', $type);
$key = end($types);
if ($resourceId !== null) {
$key .= '_' . $resourceId;
}
$this->errors[$key] = array_merge(Arr::get($this->errors, $key, []), $errors);
}
}
});
return $this;
} | [
"public",
"function",
"validator",
"(",
"$",
"type",
",",
"$",
"validator",
")",
"{",
"$",
"this",
"->",
"validators",
"[",
"$",
"type",
"]",
"=",
"$",
"validator",
";",
"$",
"this",
"->",
"resolver",
"(",
"$",
"type",
",",
"function",
"(",
"$",
"data",
",",
"$",
"resourceId",
")",
"use",
"(",
"$",
"type",
")",
"{",
"/** @var \\Drp\\JsonApiParser\\Contracts\\ValidatorExecutor[] $validators */",
"$",
"validators",
"=",
"Arr",
"::",
"wrap",
"(",
"$",
"this",
"->",
"validators",
"[",
"$",
"type",
"]",
")",
";",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"validator",
")",
"{",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"resourceId",
";",
"$",
"validator",
"->",
"with",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"$",
"validator",
"->",
"passes",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"errors",
"=",
"$",
"validator",
"->",
"errors",
"(",
")",
";",
"$",
"types",
"=",
"explode",
"(",
"'.'",
",",
"$",
"type",
")",
";",
"$",
"key",
"=",
"end",
"(",
"$",
"types",
")",
";",
"if",
"(",
"$",
"resourceId",
"!==",
"null",
")",
"{",
"$",
"key",
".=",
"'_'",
".",
"$",
"resourceId",
";",
"}",
"$",
"this",
"->",
"errors",
"[",
"$",
"key",
"]",
"=",
"array_merge",
"(",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"errors",
",",
"$",
"key",
",",
"[",
"]",
")",
",",
"$",
"errors",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a validator to be ran when the type is found.
@param string $type
@param \Drp\JsonApiParser\Contracts\ValidatorExecutor|array $validator
@return $this
@throws \Drp\JsonApiParser\Exceptions\FailedValidationException | [
"Add",
"a",
"validator",
"to",
"be",
"ran",
"when",
"the",
"type",
"is",
"found",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiValidator.php#L61-L91 |
16,310 | drpdigital/json-api-parser | src/JsonApiValidator.php | JsonApiValidator.validate | public function validate(array $input)
{
$result = $this->parse($input);
if ($result === null) {
throw new InvalidJsonException(
'Parser was unable to process the JSON due to there not being a data key.'
);
}
if (count($this->seenTypes) > 0) {
array_walk($this->presenceCheckers, function (callable $callback = null, $type) {
if ($callback !== null) {
try {
$isRequired = $callback($this->seenTypes);
} catch (FailedValidationException $exception) {
$this->errors = array_merge($this->errors, [
$type => $exception->getMessages()
]);
return;
}
if ($isRequired === false) {
return;
}
} elseif ($this->seenTypes->has($type)) {
return;
}
$this->errors[$type] = 'Missing api resource from the request.';
});
}
if (count($this->errors) > 0) {
throw new FailedValidationException($this->errors);
}
return true;
} | php | public function validate(array $input)
{
$result = $this->parse($input);
if ($result === null) {
throw new InvalidJsonException(
'Parser was unable to process the JSON due to there not being a data key.'
);
}
if (count($this->seenTypes) > 0) {
array_walk($this->presenceCheckers, function (callable $callback = null, $type) {
if ($callback !== null) {
try {
$isRequired = $callback($this->seenTypes);
} catch (FailedValidationException $exception) {
$this->errors = array_merge($this->errors, [
$type => $exception->getMessages()
]);
return;
}
if ($isRequired === false) {
return;
}
} elseif ($this->seenTypes->has($type)) {
return;
}
$this->errors[$type] = 'Missing api resource from the request.';
});
}
if (count($this->errors) > 0) {
throw new FailedValidationException($this->errors);
}
return true;
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"input",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"input",
")",
";",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidJsonException",
"(",
"'Parser was unable to process the JSON due to there not being a data key.'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"seenTypes",
")",
">",
"0",
")",
"{",
"array_walk",
"(",
"$",
"this",
"->",
"presenceCheckers",
",",
"function",
"(",
"callable",
"$",
"callback",
"=",
"null",
",",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"callback",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"isRequired",
"=",
"$",
"callback",
"(",
"$",
"this",
"->",
"seenTypes",
")",
";",
"}",
"catch",
"(",
"FailedValidationException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"errors",
",",
"[",
"$",
"type",
"=>",
"$",
"exception",
"->",
"getMessages",
"(",
")",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"isRequired",
"===",
"false",
")",
"{",
"return",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"seenTypes",
"->",
"has",
"(",
"$",
"type",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"errors",
"[",
"$",
"type",
"]",
"=",
"'Missing api resource from the request.'",
";",
"}",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"errors",
")",
">",
"0",
")",
"{",
"throw",
"new",
"FailedValidationException",
"(",
"$",
"this",
"->",
"errors",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Validate input.
@param array $input
@return bool
@throws \Drp\JsonApiParser\Exceptions\FailedValidationException
@throws \ReflectionException
@throws \Drp\JsonApiParser\Exceptions\MissingResolverException
@throws \Drp\JsonApiParser\Exceptions\InvalidJsonException | [
"Validate",
"input",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiValidator.php#L120-L159 |
16,311 | gregorybesson/PlaygroundCore | src/Service/Registry.php | Registry.register | public static function register(
$code,
$frequency,
$callback,
array $args = array()
) {
if (!is_callable($callback)) {
throw new \RuntimeException('The callback must be callable');
}
/*
* validation of $frequency (cron expression):
* will be done together when scheduling
* (errors thrown if invalid cron expression)
*/
$instance = self::getInstance();
$cronRegistry = $instance->getCronRegistry();
$cronRegistry[$code] = array(
'frequency' => $frequency,
'callback' => $callback,
'args' => $args,
);
$instance->setCronRegistry($cronRegistry);
return $instance;
} | php | public static function register(
$code,
$frequency,
$callback,
array $args = array()
) {
if (!is_callable($callback)) {
throw new \RuntimeException('The callback must be callable');
}
/*
* validation of $frequency (cron expression):
* will be done together when scheduling
* (errors thrown if invalid cron expression)
*/
$instance = self::getInstance();
$cronRegistry = $instance->getCronRegistry();
$cronRegistry[$code] = array(
'frequency' => $frequency,
'callback' => $callback,
'args' => $args,
);
$instance->setCronRegistry($cronRegistry);
return $instance;
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"code",
",",
"$",
"frequency",
",",
"$",
"callback",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The callback must be callable'",
")",
";",
"}",
"/*\n * validation of $frequency (cron expression):\n * will be done together when scheduling\n * (errors thrown if invalid cron expression)\n */",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"cronRegistry",
"=",
"$",
"instance",
"->",
"getCronRegistry",
"(",
")",
";",
"$",
"cronRegistry",
"[",
"$",
"code",
"]",
"=",
"array",
"(",
"'frequency'",
"=>",
"$",
"frequency",
",",
"'callback'",
"=>",
"$",
"callback",
",",
"'args'",
"=>",
"$",
"args",
",",
")",
";",
"$",
"instance",
"->",
"setCronRegistry",
"(",
"$",
"cronRegistry",
")",
";",
"return",
"$",
"instance",
";",
"}"
]
| register a cron job
@see Cron::trySchedule() for allowed cron expression syntax
@param string $code the cron job code / identifier
@param string $frequency cron expression
@param callable $callback the actual cron job
@param array $args args to the cron job
@return self | [
"register",
"a",
"cron",
"job"
]
| f8dfa4c7660b54354933b3c28c0cf35304a649df | https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Registry.php#L67-L93 |
16,312 | pdefreitas/Laravel-VanillaSSO | src/controllers/VanillaSSOController.php | VanillaSSOController.jsonResponse | public function jsonResponse()
{
$user = Auth::getUser();
//Change here whatever you need
$ssoUser = new SSOUser();
$ssoUser->id = $user->id;
$ssoUser->name = $user->username;
$ssoUser->email = $user->email;
$ssoUser->roles = $user->roles;
$ssoUser->profilepicture = "";
$userInfo = $ssoUser->toArray();
return VanillaSSO::WriteJsConnect($userInfo, $_GET, true);
} | php | public function jsonResponse()
{
$user = Auth::getUser();
//Change here whatever you need
$ssoUser = new SSOUser();
$ssoUser->id = $user->id;
$ssoUser->name = $user->username;
$ssoUser->email = $user->email;
$ssoUser->roles = $user->roles;
$ssoUser->profilepicture = "";
$userInfo = $ssoUser->toArray();
return VanillaSSO::WriteJsConnect($userInfo, $_GET, true);
} | [
"public",
"function",
"jsonResponse",
"(",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"getUser",
"(",
")",
";",
"//Change here whatever you need",
"$",
"ssoUser",
"=",
"new",
"SSOUser",
"(",
")",
";",
"$",
"ssoUser",
"->",
"id",
"=",
"$",
"user",
"->",
"id",
";",
"$",
"ssoUser",
"->",
"name",
"=",
"$",
"user",
"->",
"username",
";",
"$",
"ssoUser",
"->",
"email",
"=",
"$",
"user",
"->",
"email",
";",
"$",
"ssoUser",
"->",
"roles",
"=",
"$",
"user",
"->",
"roles",
";",
"$",
"ssoUser",
"->",
"profilepicture",
"=",
"\"\"",
";",
"$",
"userInfo",
"=",
"$",
"ssoUser",
"->",
"toArray",
"(",
")",
";",
"return",
"VanillaSSO",
"::",
"WriteJsConnect",
"(",
"$",
"userInfo",
",",
"$",
"_GET",
",",
"true",
")",
";",
"}"
]
| Produces jsonResponse.
@return Response | [
"Produces",
"jsonResponse",
"."
]
| f47a7c33eaf392fb6564a909f622b36ffd373759 | https://github.com/pdefreitas/Laravel-VanillaSSO/blob/f47a7c33eaf392fb6564a909f622b36ffd373759/src/controllers/VanillaSSOController.php#L16-L31 |
16,313 | blast-project/CoreBundle | src/CodeGenerator/CodeGeneratorFactory.php | CodeGeneratorFactory.create | public static function create($class, EntityManager $entityManager)
{
$rc = new \ReflectionClass($class);
$interface = 'Blast\CoreBundle\CodeGenerator\CodeGeneratorInterface';
if (!$rc->implementsInterface($interface)) {
throw new \RuntimeException("Class $class should implement $interface");
}
$codeGenerator = new $class();
$codeGenerator::setEntityManager($entityManager);
return $codeGenerator;
} | php | public static function create($class, EntityManager $entityManager)
{
$rc = new \ReflectionClass($class);
$interface = 'Blast\CoreBundle\CodeGenerator\CodeGeneratorInterface';
if (!$rc->implementsInterface($interface)) {
throw new \RuntimeException("Class $class should implement $interface");
}
$codeGenerator = new $class();
$codeGenerator::setEntityManager($entityManager);
return $codeGenerator;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"class",
",",
"EntityManager",
"$",
"entityManager",
")",
"{",
"$",
"rc",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"interface",
"=",
"'Blast\\CoreBundle\\CodeGenerator\\CodeGeneratorInterface'",
";",
"if",
"(",
"!",
"$",
"rc",
"->",
"implementsInterface",
"(",
"$",
"interface",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Class $class should implement $interface\"",
")",
";",
"}",
"$",
"codeGenerator",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"codeGenerator",
"::",
"setEntityManager",
"(",
"$",
"entityManager",
")",
";",
"return",
"$",
"codeGenerator",
";",
"}"
]
| Creates an entity code generator service.
@param string $class
@param EntityManager $entityManager
@return CodeGeneratorInterface | [
"Creates",
"an",
"entity",
"code",
"generator",
"service",
"."
]
| 7a0832758ca14e5bc5d65515532c1220df3930ae | https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/CodeGenerator/CodeGeneratorFactory.php#L27-L38 |
16,314 | discophp/framework | core/classes/Request.class.php | Request.pathPart | public function pathPart($i){
if(isset($this->pathParts[$i])){
return $this->pathParts[$i];
}//if
return null;
} | php | public function pathPart($i){
if(isset($this->pathParts[$i])){
return $this->pathParts[$i];
}//if
return null;
} | [
"public",
"function",
"pathPart",
"(",
"$",
"i",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pathParts",
"[",
"$",
"i",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pathParts",
"[",
"$",
"i",
"]",
";",
"}",
"//if",
"return",
"null",
";",
"}"
]
| Get a part of the path by index.
@param int $i The index of the path part.
@return string | [
"Get",
"a",
"part",
"of",
"the",
"path",
"by",
"index",
"."
]
| 40ff3ea5225810534195494dc6c21083da4d1356 | https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Request.class.php#L178-L183 |
16,315 | czim/laravel-pxlcms | src/Helpers/Paths.php | Paths.images | public static function images($file = null, $secure = false)
{
return asset(self::appendToPath(config('pxlcms.paths.images'), $file), $secure);
} | php | public static function images($file = null, $secure = false)
{
return asset(self::appendToPath(config('pxlcms.paths.images'), $file), $secure);
} | [
"public",
"static",
"function",
"images",
"(",
"$",
"file",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
")",
"{",
"return",
"asset",
"(",
"self",
"::",
"appendToPath",
"(",
"config",
"(",
"'pxlcms.paths.images'",
")",
",",
"$",
"file",
")",
",",
"$",
"secure",
")",
";",
"}"
]
| External path to CMS images
@param string $file file to add to path
@param bool $secure
@return string | [
"External",
"path",
"to",
"CMS",
"images"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Helpers/Paths.php#L13-L16 |
16,316 | czim/laravel-pxlcms | src/Helpers/Paths.php | Paths.imagesInternal | public static function imagesInternal($file = null)
{
return base_path(
self::appendToPath(
self::appendToPath(config('pxlcms.paths.base_internal'), config('pxlcms.paths.images')),
$file
)
);
} | php | public static function imagesInternal($file = null)
{
return base_path(
self::appendToPath(
self::appendToPath(config('pxlcms.paths.base_internal'), config('pxlcms.paths.images')),
$file
)
);
} | [
"public",
"static",
"function",
"imagesInternal",
"(",
"$",
"file",
"=",
"null",
")",
"{",
"return",
"base_path",
"(",
"self",
"::",
"appendToPath",
"(",
"self",
"::",
"appendToPath",
"(",
"config",
"(",
"'pxlcms.paths.base_internal'",
")",
",",
"config",
"(",
"'pxlcms.paths.images'",
")",
")",
",",
"$",
"file",
")",
")",
";",
"}"
]
| Internal path to CMS images
@param string $file file to add to path
@return string | [
"Internal",
"path",
"to",
"CMS",
"images"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Helpers/Paths.php#L24-L32 |
16,317 | czim/laravel-pxlcms | src/Helpers/Paths.php | Paths.appendToPath | protected static function appendToPath($path, $file)
{
if (empty($file)) return $path;
return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
} | php | protected static function appendToPath($path, $file)
{
if (empty($file)) return $path;
return rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file;
} | [
"protected",
"static",
"function",
"appendToPath",
"(",
"$",
"path",
",",
"$",
"file",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"file",
")",
")",
"return",
"$",
"path",
";",
"return",
"rtrim",
"(",
"$",
"path",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
";",
"}"
]
| Append a subpath or file to a path
@param string $path
@param string $file
@return string | [
"Append",
"a",
"subpath",
"or",
"file",
"to",
"a",
"path"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Helpers/Paths.php#L69-L74 |
16,318 | kiwiz/ecl | src/Util.php | Util.get | public static function get($arr, $key, $default=null) {
return self::exists($arr, $key) ? $arr[$key]:$default;
} | php | public static function get($arr, $key, $default=null) {
return self::exists($arr, $key) ? $arr[$key]:$default;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"arr",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"exists",
"(",
"$",
"arr",
",",
"$",
"key",
")",
"?",
"$",
"arr",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}"
]
| Return the value of a key or a default value.
@param array|\ArrayAccess $arr The array.
@param string|int $key The key.
@param mixed $default The default value to return.
@return mixed|null The value of that key. | [
"Return",
"the",
"value",
"of",
"a",
"key",
"or",
"a",
"default",
"value",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Util.php#L18-L20 |
16,319 | kiwiz/ecl | src/Util.php | Util.exists | public static function exists($arr, $key) {
// If it's an object, index directly because array_key_exists doesn't
// work with the ArrayAccess interface. Otherwise, check if it implements
// ArrayAccess and fall back to array_key_exists.
if(is_object($arr)) {
return $arr->offsetExists($key);
}
if(is_array($arr)) {
return array_key_exists($key, $arr);
}
return false;
} | php | public static function exists($arr, $key) {
// If it's an object, index directly because array_key_exists doesn't
// work with the ArrayAccess interface. Otherwise, check if it implements
// ArrayAccess and fall back to array_key_exists.
if(is_object($arr)) {
return $arr->offsetExists($key);
}
if(is_array($arr)) {
return array_key_exists($key, $arr);
}
return false;
} | [
"public",
"static",
"function",
"exists",
"(",
"$",
"arr",
",",
"$",
"key",
")",
"{",
"// If it's an object, index directly because array_key_exists doesn't",
"// work with the ArrayAccess interface. Otherwise, check if it implements",
"// ArrayAccess and fall back to array_key_exists.",
"if",
"(",
"is_object",
"(",
"$",
"arr",
")",
")",
"{",
"return",
"$",
"arr",
"->",
"offsetExists",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"arr",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Determines whether an array contains a certain key.
@param array|\ArrayAccess $arr The array.
@param string|int $key The key.
@return bool true if the key exists and false otherwise. | [
"Determines",
"whether",
"an",
"array",
"contains",
"a",
"certain",
"key",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Util.php#L28-L40 |
16,320 | kiwiz/ecl | src/Util.php | Util.pluck | public static function pluck($arr, $path) {
$ret = [];
$path = (array) $path;
foreach($arr as $v) {
$node = &$v;
$ok = true;
foreach($path as $part) {
if(!is_array($node) || !array_key_exists($part, $node)) {
$ok = false;
break;
}
$node = &$node[$part];
}
if($ok) {
$ret[] = $node;
}
}
return $ret;
} | php | public static function pluck($arr, $path) {
$ret = [];
$path = (array) $path;
foreach($arr as $v) {
$node = &$v;
$ok = true;
foreach($path as $part) {
if(!is_array($node) || !array_key_exists($part, $node)) {
$ok = false;
break;
}
$node = &$node[$part];
}
if($ok) {
$ret[] = $node;
}
}
return $ret;
} | [
"public",
"static",
"function",
"pluck",
"(",
"$",
"arr",
",",
"$",
"path",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"(",
"array",
")",
"$",
"path",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"v",
")",
"{",
"$",
"node",
"=",
"&",
"$",
"v",
";",
"$",
"ok",
"=",
"true",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"node",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"part",
",",
"$",
"node",
")",
")",
"{",
"$",
"ok",
"=",
"false",
";",
"break",
";",
"}",
"$",
"node",
"=",
"&",
"$",
"node",
"[",
"$",
"part",
"]",
";",
"}",
"if",
"(",
"$",
"ok",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Extract values from an array with the given path.
@param array $arr
@param string|string[]|int $path
@return array | [
"Extract",
"values",
"from",
"an",
"array",
"with",
"the",
"given",
"path",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Util.php#L48-L68 |
16,321 | Graphiques-Digitale/silverstripe-seo-metadata | code/SEO_Metadata_SiteConfig_DataExtension.php | SEO_Metadata_SiteConfig_DataExtension.Charset | public function Charset()
{
return ($this->owner->config()->Charset) ? $this->owner->config()->Charset : self::$Charset;
} | php | public function Charset()
{
return ($this->owner->config()->Charset) ? $this->owner->config()->Charset : self::$Charset;
} | [
"public",
"function",
"Charset",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"Charset",
")",
"?",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"Charset",
":",
"self",
"::",
"$",
"Charset",
";",
"}"
]
| Character set.
Gets the character set from configuration, or uses the class-defined default.
@return string | [
"Character",
"set",
"."
]
| f92128688a60b6c6b514b6efb1486ac60f4a8e03 | https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteConfig_DataExtension.php#L162-L165 |
16,322 | Graphiques-Digitale/silverstripe-seo-metadata | code/SEO_Metadata_SiteConfig_DataExtension.php | SEO_Metadata_SiteConfig_DataExtension.getTitleFields | public function getTitleFields() {
return array(
// Information
LabelField::create('FaviconDescription', 'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href="https://moz.com/learn/seo/title-tag" target="_blank">Title Tag - Learn SEO - Mozilla</a>')
->addExtraClass('information'),
// Title Order
DropdownField::create('TitleOrder', 'Page Title Order', self::$TitleOrderOptions),
// Title Separator
TextField::create('TitleSeparator', 'Page Title Separator')
->setAttribute('placeholder', self::$TitleSeparatorDefault)
->setAttribute('size', 1)
->setMaxLength(1)
->setDescription('max 1 character'),
// Title
TextField::create('Title', 'Website Name'),
// Tagline Separator
TextField::create('TaglineSeparator', 'Tagline Separator')
->setAttribute('placeholder', self::$TaglineSeparatorDefault)
->setAttribute('size', 1)
->setMaxLength(1)
->setDescription('max 1 character'),
// Tagline
TextField::create('Tagline', 'Tagline')
->setDescription('optional')
);
} | php | public function getTitleFields() {
return array(
// Information
LabelField::create('FaviconDescription', 'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href="https://moz.com/learn/seo/title-tag" target="_blank">Title Tag - Learn SEO - Mozilla</a>')
->addExtraClass('information'),
// Title Order
DropdownField::create('TitleOrder', 'Page Title Order', self::$TitleOrderOptions),
// Title Separator
TextField::create('TitleSeparator', 'Page Title Separator')
->setAttribute('placeholder', self::$TitleSeparatorDefault)
->setAttribute('size', 1)
->setMaxLength(1)
->setDescription('max 1 character'),
// Title
TextField::create('Title', 'Website Name'),
// Tagline Separator
TextField::create('TaglineSeparator', 'Tagline Separator')
->setAttribute('placeholder', self::$TaglineSeparatorDefault)
->setAttribute('size', 1)
->setMaxLength(1)
->setDescription('max 1 character'),
// Tagline
TextField::create('Tagline', 'Tagline')
->setDescription('optional')
);
} | [
"public",
"function",
"getTitleFields",
"(",
")",
"{",
"return",
"array",
"(",
"// Information",
"LabelField",
"::",
"create",
"(",
"'FaviconDescription'",
",",
"'A title tag is the main text that describes an online document. Title elements have long been considered one of the most important on-page SEO elements (the most important being overall content), and appear in three key places: browsers, search engine results pages, and external websites.<br />@ <a href=\"https://moz.com/learn/seo/title-tag\" target=\"_blank\">Title Tag - Learn SEO - Mozilla</a>'",
")",
"->",
"addExtraClass",
"(",
"'information'",
")",
",",
"// Title Order",
"DropdownField",
"::",
"create",
"(",
"'TitleOrder'",
",",
"'Page Title Order'",
",",
"self",
"::",
"$",
"TitleOrderOptions",
")",
",",
"// Title Separator",
"TextField",
"::",
"create",
"(",
"'TitleSeparator'",
",",
"'Page Title Separator'",
")",
"->",
"setAttribute",
"(",
"'placeholder'",
",",
"self",
"::",
"$",
"TitleSeparatorDefault",
")",
"->",
"setAttribute",
"(",
"'size'",
",",
"1",
")",
"->",
"setMaxLength",
"(",
"1",
")",
"->",
"setDescription",
"(",
"'max 1 character'",
")",
",",
"// Title",
"TextField",
"::",
"create",
"(",
"'Title'",
",",
"'Website Name'",
")",
",",
"// Tagline Separator",
"TextField",
"::",
"create",
"(",
"'TaglineSeparator'",
",",
"'Tagline Separator'",
")",
"->",
"setAttribute",
"(",
"'placeholder'",
",",
"self",
"::",
"$",
"TaglineSeparatorDefault",
")",
"->",
"setAttribute",
"(",
"'size'",
",",
"1",
")",
"->",
"setMaxLength",
"(",
"1",
")",
"->",
"setDescription",
"(",
"'max 1 character'",
")",
",",
"// Tagline",
"TextField",
"::",
"create",
"(",
"'Tagline'",
",",
"'Tagline'",
")",
"->",
"setDescription",
"(",
"'optional'",
")",
")",
";",
"}"
]
| Gets the title fields.
This approach for getting fields for updateCMSFields is to be duplicated through all other modules to reduce complexity.
@TODO i18n implementation
@return array | [
"Gets",
"the",
"title",
"fields",
"."
]
| f92128688a60b6c6b514b6efb1486ac60f4a8e03 | https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteConfig_DataExtension.php#L215-L240 |
16,323 | ARCANEDEV/SpamBlocker | src/SpamBlocker.php | SpamBlocker.load | public function load()
{
$this->checkSource();
$this->spammers = $this->cacheSpammers(function () {
return SpammerCollection::load(
file($this->source, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
);
});
return $this;
} | php | public function load()
{
$this->checkSource();
$this->spammers = $this->cacheSpammers(function () {
return SpammerCollection::load(
file($this->source, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
);
});
return $this;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"this",
"->",
"checkSource",
"(",
")",
";",
"$",
"this",
"->",
"spammers",
"=",
"$",
"this",
"->",
"cacheSpammers",
"(",
"function",
"(",
")",
"{",
"return",
"SpammerCollection",
"::",
"load",
"(",
"file",
"(",
"$",
"this",
"->",
"source",
",",
"FILE_IGNORE_NEW_LINES",
"|",
"FILE_SKIP_EMPTY_LINES",
")",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Load spammers.
@return self | [
"Load",
"spammers",
"."
]
| 708c9d5363616e0b257451256c4ca9fb9a9ff55f | https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlocker.php#L183-L194 |
16,324 | ARCANEDEV/SpamBlocker | src/SpamBlocker.php | SpamBlocker.isBlocked | public function isBlocked($host)
{
$host = parse_url($host, PHP_URL_HOST);
$host = utf8_encode(trim($host));
if (empty($host)) return false;
$fullDomain = $this->getFullDomain($host);
$rootDomain = $this->getRootDomain($fullDomain);
return $this->spammers()
->whereHostIn([$fullDomain, $rootDomain])
->whereBlocked()
->count() > 0;
} | php | public function isBlocked($host)
{
$host = parse_url($host, PHP_URL_HOST);
$host = utf8_encode(trim($host));
if (empty($host)) return false;
$fullDomain = $this->getFullDomain($host);
$rootDomain = $this->getRootDomain($fullDomain);
return $this->spammers()
->whereHostIn([$fullDomain, $rootDomain])
->whereBlocked()
->count() > 0;
} | [
"public",
"function",
"isBlocked",
"(",
"$",
"host",
")",
"{",
"$",
"host",
"=",
"parse_url",
"(",
"$",
"host",
",",
"PHP_URL_HOST",
")",
";",
"$",
"host",
"=",
"utf8_encode",
"(",
"trim",
"(",
"$",
"host",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"host",
")",
")",
"return",
"false",
";",
"$",
"fullDomain",
"=",
"$",
"this",
"->",
"getFullDomain",
"(",
"$",
"host",
")",
";",
"$",
"rootDomain",
"=",
"$",
"this",
"->",
"getRootDomain",
"(",
"$",
"fullDomain",
")",
";",
"return",
"$",
"this",
"->",
"spammers",
"(",
")",
"->",
"whereHostIn",
"(",
"[",
"$",
"fullDomain",
",",
"$",
"rootDomain",
"]",
")",
"->",
"whereBlocked",
"(",
")",
"->",
"count",
"(",
")",
">",
"0",
";",
"}"
]
| Check if the given host is blocked.
@param string $host
@return bool | [
"Check",
"if",
"the",
"given",
"host",
"is",
"blocked",
"."
]
| 708c9d5363616e0b257451256c4ca9fb9a9ff55f | https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlocker.php#L259-L273 |
16,325 | ARCANEDEV/SpamBlocker | src/SpamBlocker.php | SpamBlocker.getRootDomain | private function getRootDomain($domain)
{
$domainParts = explode('.', $domain);
$count = count($domainParts);
return $count > 1
? $domainParts[$count - 2].'.'.$domainParts[$count - 1]
: $domainParts[0];
} | php | private function getRootDomain($domain)
{
$domainParts = explode('.', $domain);
$count = count($domainParts);
return $count > 1
? $domainParts[$count - 2].'.'.$domainParts[$count - 1]
: $domainParts[0];
} | [
"private",
"function",
"getRootDomain",
"(",
"$",
"domain",
")",
"{",
"$",
"domainParts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"domain",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"domainParts",
")",
";",
"return",
"$",
"count",
">",
"1",
"?",
"$",
"domainParts",
"[",
"$",
"count",
"-",
"2",
"]",
".",
"'.'",
".",
"$",
"domainParts",
"[",
"$",
"count",
"-",
"1",
"]",
":",
"$",
"domainParts",
"[",
"0",
"]",
";",
"}"
]
| Get the root domain.
@param string $domain
@return string | [
"Get",
"the",
"root",
"domain",
"."
]
| 708c9d5363616e0b257451256c4ca9fb9a9ff55f | https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlocker.php#L326-L334 |
16,326 | ARCANEDEV/SpamBlocker | src/SpamBlocker.php | SpamBlocker.cacheSpammers | private function cacheSpammers(Closure $callback)
{
return cache()->remember($this->cacheKey, $this->cacheExpires, $callback);
} | php | private function cacheSpammers(Closure $callback)
{
return cache()->remember($this->cacheKey, $this->cacheExpires, $callback);
} | [
"private",
"function",
"cacheSpammers",
"(",
"Closure",
"$",
"callback",
")",
"{",
"return",
"cache",
"(",
")",
"->",
"remember",
"(",
"$",
"this",
"->",
"cacheKey",
",",
"$",
"this",
"->",
"cacheExpires",
",",
"$",
"callback",
")",
";",
"}"
]
| Cache the spammers.
@param \Closure $callback
@return \Arcanedev\SpamBlocker\Entities\SpammerCollection | [
"Cache",
"the",
"spammers",
"."
]
| 708c9d5363616e0b257451256c4ca9fb9a9ff55f | https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlocker.php#L355-L358 |
16,327 | stubbles/stubbles-webapp-core | src/main/php/auth/Token.php | Token.create | public static function create(User $user, string $salt): self
{
return new self(md5($salt . serialize([
$user->name(),
$user->firstName(),
$user->lastName(),
$user->mailAddress(),
self::createRandomContent()
])));
} | php | public static function create(User $user, string $salt): self
{
return new self(md5($salt . serialize([
$user->name(),
$user->firstName(),
$user->lastName(),
$user->mailAddress(),
self::createRandomContent()
])));
} | [
"public",
"static",
"function",
"create",
"(",
"User",
"$",
"user",
",",
"string",
"$",
"salt",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"md5",
"(",
"$",
"salt",
".",
"serialize",
"(",
"[",
"$",
"user",
"->",
"name",
"(",
")",
",",
"$",
"user",
"->",
"firstName",
"(",
")",
",",
"$",
"user",
"->",
"lastName",
"(",
")",
",",
"$",
"user",
"->",
"mailAddress",
"(",
")",
",",
"self",
"::",
"createRandomContent",
"(",
")",
"]",
")",
")",
")",
";",
"}"
]
| creates token for given user
@param \stubbles\webapp\auth\User $user user to create token for
@param string $salt salt to use for token creation
@return \stubbles\webapp\auth\Token | [
"creates",
"token",
"for",
"given",
"user"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/Token.php#L43-L52 |
16,328 | phossa2/middleware | src/Middleware/Middleware/MiddlewareAbstract.php | MiddlewareAbstract.process | public function process(
RequestInterface $request,
ResponseInterface $response,
DelegateInterface $next = null
) {
// before
$response = $this->before($request, $response);
// next middleware
if ($next) {
$response = $next->next($request, $response);
}
// after
return $this->after($request, $response);
} | php | public function process(
RequestInterface $request,
ResponseInterface $response,
DelegateInterface $next = null
) {
// before
$response = $this->before($request, $response);
// next middleware
if ($next) {
$response = $next->next($request, $response);
}
// after
return $this->after($request, $response);
} | [
"public",
"function",
"process",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"DelegateInterface",
"$",
"next",
"=",
"null",
")",
"{",
"// before",
"$",
"response",
"=",
"$",
"this",
"->",
"before",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"// next middleware",
"if",
"(",
"$",
"next",
")",
"{",
"$",
"response",
"=",
"$",
"next",
"->",
"next",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"// after",
"return",
"$",
"this",
"->",
"after",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
]
| Make process logic clear !
{@inheritDoc} | [
"Make",
"process",
"logic",
"clear",
"!"
]
| 518e97ae48077f2c11adcd3c2393830ed7ab7ce7 | https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Middleware/MiddlewareAbstract.php#L40-L55 |
16,329 | sanpii/assetic | src/Assetic/Filter/BaseProcessFilter.php | BaseProcessFilter.createProcessBuilder | protected function createProcessBuilder(array $arguments = array())
{
$pb = new Process(implode(' ', $arguments));
if (null !== $this->timeout) {
$pb->setTimeout($this->timeout);
}
return $pb;
} | php | protected function createProcessBuilder(array $arguments = array())
{
$pb = new Process(implode(' ', $arguments));
if (null !== $this->timeout) {
$pb->setTimeout($this->timeout);
}
return $pb;
} | [
"protected",
"function",
"createProcessBuilder",
"(",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"pb",
"=",
"new",
"Process",
"(",
"implode",
"(",
"' '",
",",
"$",
"arguments",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"timeout",
")",
"{",
"$",
"pb",
"->",
"setTimeout",
"(",
"$",
"this",
"->",
"timeout",
")",
";",
"}",
"return",
"$",
"pb",
";",
"}"
]
| Creates a new process builder.
@param array $arguments An optional array of arguments
@return Process A new process builder | [
"Creates",
"a",
"new",
"process",
"builder",
"."
]
| 5c446eee54cc396cbbd6e252108f430e6e617c95 | https://github.com/sanpii/assetic/blob/5c446eee54cc396cbbd6e252108f430e6e617c95/src/Assetic/Filter/BaseProcessFilter.php#L40-L49 |
16,330 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtNamespace/NamespaceRule.php | NamespaceRule.setPrefix | protected function setPrefix($prefix)
{
if (is_string($prefix)) {
$this->prefix = $prefix;
return $this;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($prefix). "' for argument 'prefix' given."
);
}
} | php | protected function setPrefix($prefix)
{
if (is_string($prefix)) {
$this->prefix = $prefix;
return $this;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($prefix). "' for argument 'prefix' given."
);
}
} | [
"protected",
"function",
"setPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"prefix",
")",
")",
"{",
"$",
"this",
"->",
"prefix",
"=",
"$",
"prefix",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"prefix",
")",
".",
"\"' for argument 'prefix' given.\"",
")",
";",
"}",
"}"
]
| Sets the namespace prefix.
@param string $prefix
@return $this | [
"Sets",
"the",
"namespace",
"prefix",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtNamespace/NamespaceRule.php#L73-L84 |
16,331 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtNamespace/NamespaceRule.php | NamespaceRule.parseRuleString | protected function parseRuleString($ruleString)
{
if (is_string($ruleString)) {
$charset = $this->getCharset();
// Remove at-rule and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@namespace[ \r\n\t\f]+/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
// Remove trailing semicolon
$ruleString = rtrim($ruleString, ";");
$isEscaped = false;
$inFunction = false;
$parts = [];
$currentPart = "";
for ($i = 0, $j = mb_strlen($ruleString, $charset); $i < $j; $i++) {
$char = mb_substr($ruleString, $i, 1, $charset);
if ($char === "\\") {
if ($isEscaped === false) {
$isEscaped = true;
} else {
$isEscaped = false;
}
} else {
if ($char === " ") {
if ($isEscaped === false) {
if ($inFunction == false) {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
$parts[] = trim($currentPart, " \r\n\t\f");
$currentPart = "";
}
}
} else {
$currentPart .= $char;
}
} elseif ($isEscaped === false && $char === "(") {
$inFunction = true;
$currentPart .= $char;
} elseif ($isEscaped === false && $char === ")") {
$inFunction = false;
$currentPart .= $char;
} else {
$currentPart .= $char;
}
}
// Reset escaped flag
if ($isEscaped === true && $char !== "\\") {
$isEscaped = false;
}
}
if ($currentPart !== "") {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
$parts[] = trim($currentPart, " \r\n\t\f");
}
}
foreach ($parts as $key => $value) {
$parts[$key] = Placeholder::replaceStringPlaceholders($value);
}
$countParts = count($parts);
if ($countParts === 2) {
$this->setPrefix($parts[0]);
// Get URL value
$name = Url::extractUrl($parts[1]);
$this->setName($name);
} elseif ($countParts === 1) {
// Get URL value
$name = Url::extractUrl($parts[0]);
$this->setName($name);
} else {
// ERROR
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given."
);
}
} | php | protected function parseRuleString($ruleString)
{
if (is_string($ruleString)) {
$charset = $this->getCharset();
// Remove at-rule and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@namespace[ \r\n\t\f]+/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
// Remove trailing semicolon
$ruleString = rtrim($ruleString, ";");
$isEscaped = false;
$inFunction = false;
$parts = [];
$currentPart = "";
for ($i = 0, $j = mb_strlen($ruleString, $charset); $i < $j; $i++) {
$char = mb_substr($ruleString, $i, 1, $charset);
if ($char === "\\") {
if ($isEscaped === false) {
$isEscaped = true;
} else {
$isEscaped = false;
}
} else {
if ($char === " ") {
if ($isEscaped === false) {
if ($inFunction == false) {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
$parts[] = trim($currentPart, " \r\n\t\f");
$currentPart = "";
}
}
} else {
$currentPart .= $char;
}
} elseif ($isEscaped === false && $char === "(") {
$inFunction = true;
$currentPart .= $char;
} elseif ($isEscaped === false && $char === ")") {
$inFunction = false;
$currentPart .= $char;
} else {
$currentPart .= $char;
}
}
// Reset escaped flag
if ($isEscaped === true && $char !== "\\") {
$isEscaped = false;
}
}
if ($currentPart !== "") {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
$parts[] = trim($currentPart, " \r\n\t\f");
}
}
foreach ($parts as $key => $value) {
$parts[$key] = Placeholder::replaceStringPlaceholders($value);
}
$countParts = count($parts);
if ($countParts === 2) {
$this->setPrefix($parts[0]);
// Get URL value
$name = Url::extractUrl($parts[1]);
$this->setName($name);
} elseif ($countParts === 1) {
// Get URL value
$name = Url::extractUrl($parts[0]);
$this->setName($name);
} else {
// ERROR
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given."
);
}
} | [
"protected",
"function",
"parseRuleString",
"(",
"$",
"ruleString",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"ruleString",
")",
")",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"getCharset",
"(",
")",
";",
"// Remove at-rule and unnecessary white-spaces",
"$",
"ruleString",
"=",
"preg_replace",
"(",
"'/^[ \\r\\n\\t\\f]*@namespace[ \\r\\n\\t\\f]+/i'",
",",
"''",
",",
"$",
"ruleString",
")",
";",
"$",
"ruleString",
"=",
"trim",
"(",
"$",
"ruleString",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"// Remove trailing semicolon",
"$",
"ruleString",
"=",
"rtrim",
"(",
"$",
"ruleString",
",",
"\";\"",
")",
";",
"$",
"isEscaped",
"=",
"false",
";",
"$",
"inFunction",
"=",
"false",
";",
"$",
"parts",
"=",
"[",
"]",
";",
"$",
"currentPart",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"j",
"=",
"mb_strlen",
"(",
"$",
"ruleString",
",",
"$",
"charset",
")",
";",
"$",
"i",
"<",
"$",
"j",
";",
"$",
"i",
"++",
")",
"{",
"$",
"char",
"=",
"mb_substr",
"(",
"$",
"ruleString",
",",
"$",
"i",
",",
"1",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"char",
"===",
"\"\\\\\"",
")",
"{",
"if",
"(",
"$",
"isEscaped",
"===",
"false",
")",
"{",
"$",
"isEscaped",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isEscaped",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"char",
"===",
"\" \"",
")",
"{",
"if",
"(",
"$",
"isEscaped",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"inFunction",
"==",
"false",
")",
"{",
"$",
"currentPart",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"$",
"currentPart",
"=",
"\"\"",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"}",
"elseif",
"(",
"$",
"isEscaped",
"===",
"false",
"&&",
"$",
"char",
"===",
"\"(\"",
")",
"{",
"$",
"inFunction",
"=",
"true",
";",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"elseif",
"(",
"$",
"isEscaped",
"===",
"false",
"&&",
"$",
"char",
"===",
"\")\"",
")",
"{",
"$",
"inFunction",
"=",
"false",
";",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"else",
"{",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"}",
"// Reset escaped flag",
"if",
"(",
"$",
"isEscaped",
"===",
"true",
"&&",
"$",
"char",
"!==",
"\"\\\\\"",
")",
"{",
"$",
"isEscaped",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"$",
"currentPart",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"parts",
"[",
"$",
"key",
"]",
"=",
"Placeholder",
"::",
"replaceStringPlaceholders",
"(",
"$",
"value",
")",
";",
"}",
"$",
"countParts",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"countParts",
"===",
"2",
")",
"{",
"$",
"this",
"->",
"setPrefix",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"// Get URL value",
"$",
"name",
"=",
"Url",
"::",
"extractUrl",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"$",
"this",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"elseif",
"(",
"$",
"countParts",
"===",
"1",
")",
"{",
"// Get URL value",
"$",
"name",
"=",
"Url",
"::",
"extractUrl",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"// ERROR",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"ruleString",
")",
".",
"\"' for argument 'ruleString' given.\"",
")",
";",
"}",
"}"
]
| Parses the namespace rule.
@param string $ruleString | [
"Parses",
"the",
"namespace",
"rule",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtNamespace/NamespaceRule.php#L101-L188 |
16,332 | sibds/yii2-activerecord | ActiveRecord.php | ActiveRecord.duplicate | public function duplicate() {
$this->isNewRecord = true;
foreach ($this->primaryKey() as $key) {
$this->$key = null;
}
if ($this->save()) {
return $this;
}
return null;
} | php | public function duplicate() {
$this->isNewRecord = true;
foreach ($this->primaryKey() as $key) {
$this->$key = null;
}
if ($this->save()) {
return $this;
}
return null;
} | [
"public",
"function",
"duplicate",
"(",
")",
"{",
"$",
"this",
"->",
"isNewRecord",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"primaryKey",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"return",
"null",
";",
"}"
]
| Duplicate entries in the table.
@return $this|null | [
"Duplicate",
"entries",
"in",
"the",
"table",
"."
]
| 806b6b1e07e91e1bb526c61f0dbd17bd82d25f7f | https://github.com/sibds/yii2-activerecord/blob/806b6b1e07e91e1bb526c61f0dbd17bd82d25f7f/ActiveRecord.php#L124-L135 |
16,333 | link0/profiler | src/Link0/Profiler/Profiler.php | Profiler.setDefaultPreferredProfileAdapters | private function setDefaultPreferredProfileAdapters($flags, $options)
{
$this->preferredProfilerAdapters = array(
new ProfilerAdapter\UprofilerAdapter($flags, $options),
new ProfilerAdapter\XhprofAdapter($flags, $options),
new ProfilerAdapter\NullAdapter($flags, $options),
);
} | php | private function setDefaultPreferredProfileAdapters($flags, $options)
{
$this->preferredProfilerAdapters = array(
new ProfilerAdapter\UprofilerAdapter($flags, $options),
new ProfilerAdapter\XhprofAdapter($flags, $options),
new ProfilerAdapter\NullAdapter($flags, $options),
);
} | [
"private",
"function",
"setDefaultPreferredProfileAdapters",
"(",
"$",
"flags",
",",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"preferredProfilerAdapters",
"=",
"array",
"(",
"new",
"ProfilerAdapter",
"\\",
"UprofilerAdapter",
"(",
"$",
"flags",
",",
"$",
"options",
")",
",",
"new",
"ProfilerAdapter",
"\\",
"XhprofAdapter",
"(",
"$",
"flags",
",",
"$",
"options",
")",
",",
"new",
"ProfilerAdapter",
"\\",
"NullAdapter",
"(",
"$",
"flags",
",",
"$",
"options",
")",
",",
")",
";",
"}"
]
| Sets default preferred profile adapters
@param int $flags
@param array $options | [
"Sets",
"default",
"preferred",
"profile",
"adapters"
]
| 0573073ff029743734de747619ab65ab2476052d | https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/Profiler.php#L69-L76 |
16,334 | link0/profiler | src/Link0/Profiler/Profiler.php | Profiler.addInternalIgnoreFunctions | private function addInternalIgnoreFunctions($options)
{
if(isset($options['ignored_functions']) === false) {
$options['ignored_functions'] = array();
}
$options['ignored_functions'] = array_merge($options['ignored_functions'], array(
'xhprof_disable',
'Link0\Profiler\ProfilerAdapter\XhprofAdapter::stop',
'Link0\Profiler\ProfilerAdapter\UprofilerAdapter::stop',
'Link0\Profiler\ProfilerAdapter\NullAdapter::stop',
'Link0\Profiler\ProfilerAdapter::stop',
'Link0\Profiler\ProfilerAdapter::isRunning',
'Link0\Profiler\Profiler::getProfilerAdapter',
'Link0\Profiler\Profiler::getProfileFactory',
'Link0\Profiler\Profiler::stop',
'Link0\Profiler\Profiler::isRunning',
'Link0\Profiler\Profiler::__destruct',
));
return $options;
} | php | private function addInternalIgnoreFunctions($options)
{
if(isset($options['ignored_functions']) === false) {
$options['ignored_functions'] = array();
}
$options['ignored_functions'] = array_merge($options['ignored_functions'], array(
'xhprof_disable',
'Link0\Profiler\ProfilerAdapter\XhprofAdapter::stop',
'Link0\Profiler\ProfilerAdapter\UprofilerAdapter::stop',
'Link0\Profiler\ProfilerAdapter\NullAdapter::stop',
'Link0\Profiler\ProfilerAdapter::stop',
'Link0\Profiler\ProfilerAdapter::isRunning',
'Link0\Profiler\Profiler::getProfilerAdapter',
'Link0\Profiler\Profiler::getProfileFactory',
'Link0\Profiler\Profiler::stop',
'Link0\Profiler\Profiler::isRunning',
'Link0\Profiler\Profiler::__destruct',
));
return $options;
} | [
"private",
"function",
"addInternalIgnoreFunctions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'ignored_functions'",
"]",
")",
"===",
"false",
")",
"{",
"$",
"options",
"[",
"'ignored_functions'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"options",
"[",
"'ignored_functions'",
"]",
"=",
"array_merge",
"(",
"$",
"options",
"[",
"'ignored_functions'",
"]",
",",
"array",
"(",
"'xhprof_disable'",
",",
"'Link0\\Profiler\\ProfilerAdapter\\XhprofAdapter::stop'",
",",
"'Link0\\Profiler\\ProfilerAdapter\\UprofilerAdapter::stop'",
",",
"'Link0\\Profiler\\ProfilerAdapter\\NullAdapter::stop'",
",",
"'Link0\\Profiler\\ProfilerAdapter::stop'",
",",
"'Link0\\Profiler\\ProfilerAdapter::isRunning'",
",",
"'Link0\\Profiler\\Profiler::getProfilerAdapter'",
",",
"'Link0\\Profiler\\Profiler::getProfileFactory'",
",",
"'Link0\\Profiler\\Profiler::stop'",
",",
"'Link0\\Profiler\\Profiler::isRunning'",
",",
"'Link0\\Profiler\\Profiler::__destruct'",
",",
")",
")",
";",
"return",
"$",
"options",
";",
"}"
]
| Adds internal methods for ignored_functions
@param array $options
@return array $options | [
"Adds",
"internal",
"methods",
"for",
"ignored_functions"
]
| 0573073ff029743734de747619ab65ab2476052d | https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/Profiler.php#L84-L105 |
16,335 | link0/profiler | src/Link0/Profiler/Profiler.php | Profiler.stop | public function stop()
{
// Create a new profile based upon the data of the adapter
$profile = $this->getProfileFactory()->create(
$this->getProfilerAdapter()->stop(),
$this->getApplicationData(),
$_SERVER // TODO: Don't want to use this directly, do something smarter
);
// Notify and persist the profile on the persistence service
$this->getPersistenceService()->persist($profile);
// Return the profile for further handling
return $profile;
} | php | public function stop()
{
// Create a new profile based upon the data of the adapter
$profile = $this->getProfileFactory()->create(
$this->getProfilerAdapter()->stop(),
$this->getApplicationData(),
$_SERVER // TODO: Don't want to use this directly, do something smarter
);
// Notify and persist the profile on the persistence service
$this->getPersistenceService()->persist($profile);
// Return the profile for further handling
return $profile;
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"// Create a new profile based upon the data of the adapter",
"$",
"profile",
"=",
"$",
"this",
"->",
"getProfileFactory",
"(",
")",
"->",
"create",
"(",
"$",
"this",
"->",
"getProfilerAdapter",
"(",
")",
"->",
"stop",
"(",
")",
",",
"$",
"this",
"->",
"getApplicationData",
"(",
")",
",",
"$",
"_SERVER",
"// TODO: Don't want to use this directly, do something smarter",
")",
";",
"// Notify and persist the profile on the persistence service",
"$",
"this",
"->",
"getPersistenceService",
"(",
")",
"->",
"persist",
"(",
"$",
"profile",
")",
";",
"// Return the profile for further handling",
"return",
"$",
"profile",
";",
"}"
]
| Stops profiling and persists and returns the Profile object
@return Profile | [
"Stops",
"profiling",
"and",
"persists",
"and",
"returns",
"the",
"Profile",
"object"
]
| 0573073ff029743734de747619ab65ab2476052d | https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/Profiler.php#L254-L268 |
16,336 | Nayjest/Tree | src/Tree.php | Tree.build | public function build()
{
if ($this->updateRequired) {
$this->updateRequired = false;
foreach ($this->nodes as $node) {
if ($node->parent()) {
$node->unlock()->detach();
}
}
$this->root->addChildren($this->builder->build($this->hierarchy, $this->nodes->toArray()));
foreach ($this->nodes as $node) {
if ($node->parent() === $this->root || $this->nodes->contains($node->parent())) {
$node->lock();
}
}
}
} | php | public function build()
{
if ($this->updateRequired) {
$this->updateRequired = false;
foreach ($this->nodes as $node) {
if ($node->parent()) {
$node->unlock()->detach();
}
}
$this->root->addChildren($this->builder->build($this->hierarchy, $this->nodes->toArray()));
foreach ($this->nodes as $node) {
if ($node->parent() === $this->root || $this->nodes->contains($node->parent())) {
$node->lock();
}
}
}
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"updateRequired",
")",
"{",
"$",
"this",
"->",
"updateRequired",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"parent",
"(",
")",
")",
"{",
"$",
"node",
"->",
"unlock",
"(",
")",
"->",
"detach",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"root",
"->",
"addChildren",
"(",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"this",
"->",
"hierarchy",
",",
"$",
"this",
"->",
"nodes",
"->",
"toArray",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"parent",
"(",
")",
"===",
"$",
"this",
"->",
"root",
"||",
"$",
"this",
"->",
"nodes",
"->",
"contains",
"(",
"$",
"node",
"->",
"parent",
"(",
")",
")",
")",
"{",
"$",
"node",
"->",
"lock",
"(",
")",
";",
"}",
"}",
"}",
"}"
]
| Builds tree based on its nodes registry and hierarchy configuration
if structure update required. | [
"Builds",
"tree",
"based",
"on",
"its",
"nodes",
"registry",
"and",
"hierarchy",
"configuration",
"if",
"structure",
"update",
"required",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L129-L145 |
16,337 | Nayjest/Tree | src/Tree.php | Tree.replace | public function replace($nodeName, ChildNodeInterface $node)
{
$this->removeNodeFromList($nodeName);
$this->nodes->set($nodeName, $node);
$this->updateRequired = true;
return $this;
} | php | public function replace($nodeName, ChildNodeInterface $node)
{
$this->removeNodeFromList($nodeName);
$this->nodes->set($nodeName, $node);
$this->updateRequired = true;
return $this;
} | [
"public",
"function",
"replace",
"(",
"$",
"nodeName",
",",
"ChildNodeInterface",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"removeNodeFromList",
"(",
"$",
"nodeName",
")",
";",
"$",
"this",
"->",
"nodes",
"->",
"set",
"(",
"$",
"nodeName",
",",
"$",
"node",
")",
";",
"$",
"this",
"->",
"updateRequired",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
]
| Replaces named tree node to new one.
@param string $nodeName
@param ChildNodeInterface $node
@return $this | [
"Replaces",
"named",
"tree",
"node",
"to",
"new",
"one",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L177-L184 |
16,338 | Nayjest/Tree | src/Tree.php | Tree.addMany | public function addMany($parentName, array $namedItems, $prepend = false)
{
foreach ($namedItems as $name => $item) {
$this->add($parentName, $name, $item, $prepend);
}
return $this;
} | php | public function addMany($parentName, array $namedItems, $prepend = false)
{
foreach ($namedItems as $name => $item) {
$this->add($parentName, $name, $item, $prepend);
}
return $this;
} | [
"public",
"function",
"addMany",
"(",
"$",
"parentName",
",",
"array",
"$",
"namedItems",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"namedItems",
"as",
"$",
"name",
"=>",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"parentName",
",",
"$",
"name",
",",
"$",
"item",
",",
"$",
"prepend",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds multiple nodes to tree.
@param string|null $parentName root node will be used if null
@param array $namedItems array with nodes where keys are node names
@param bool $prepend if true, nodes will be prepended, otherwise appended to parent
@return $this | [
"Adds",
"multiple",
"nodes",
"to",
"tree",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L194-L201 |
16,339 | Nayjest/Tree | src/Tree.php | Tree.move | public function move($nodeName, $newParentName, $prepend = false)
{
if (!$this->nodes->hasKey($nodeName)) {
throw new NodeNotFoundException();
}
$node = $this->nodes->get($nodeName);
$this->remove($nodeName);
$this->add($newParentName, $nodeName, $node, $prepend);
return $this;
} | php | public function move($nodeName, $newParentName, $prepend = false)
{
if (!$this->nodes->hasKey($nodeName)) {
throw new NodeNotFoundException();
}
$node = $this->nodes->get($nodeName);
$this->remove($nodeName);
$this->add($newParentName, $nodeName, $node, $prepend);
return $this;
} | [
"public",
"function",
"move",
"(",
"$",
"nodeName",
",",
"$",
"newParentName",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"nodes",
"->",
"hasKey",
"(",
"$",
"nodeName",
")",
")",
"{",
"throw",
"new",
"NodeNotFoundException",
"(",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"nodes",
"->",
"get",
"(",
"$",
"nodeName",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"nodeName",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"newParentName",
",",
"$",
"nodeName",
",",
"$",
"node",
",",
"$",
"prepend",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Moves node to another parent.
@param string $nodeName target node name
@param string|null $newParentName parent node name; root will be used if null
@param bool $prepend
@return $this | [
"Moves",
"node",
"to",
"another",
"parent",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L233-L243 |
16,340 | Nayjest/Tree | src/Tree.php | Tree.remove | public function remove($nodeName)
{
$children = self::removeTreeNode($this->hierarchy, $nodeName);
// @todo remove all children
$this->removeNodeFromList($nodeName);
$this->updateRequired = true;
return $this;
} | php | public function remove($nodeName)
{
$children = self::removeTreeNode($this->hierarchy, $nodeName);
// @todo remove all children
$this->removeNodeFromList($nodeName);
$this->updateRequired = true;
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"nodeName",
")",
"{",
"$",
"children",
"=",
"self",
"::",
"removeTreeNode",
"(",
"$",
"this",
"->",
"hierarchy",
",",
"$",
"nodeName",
")",
";",
"// @todo remove all children",
"$",
"this",
"->",
"removeNodeFromList",
"(",
"$",
"nodeName",
")",
";",
"$",
"this",
"->",
"updateRequired",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
]
| Removes node by its name.
@param string $nodeName
@return $this | [
"Removes",
"node",
"by",
"its",
"name",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L252-L260 |
16,341 | Nayjest/Tree | src/Tree.php | Tree.add | protected function add($parentName = null, $nodeName, ChildNodeInterface $node, $prepend = false)
{
if (!self::addTreeNode($this->hierarchy, $parentName, $nodeName, $prepend)) {
throw new NodeNotFoundException(
"Can't add '$nodeName' node to '$parentName': '$parentName' node not found."
);
}
$this->removeNodeFromList($nodeName);
$this->nodes->set($nodeName, $node);
$this->updateRequired = true;
return $this;
} | php | protected function add($parentName = null, $nodeName, ChildNodeInterface $node, $prepend = false)
{
if (!self::addTreeNode($this->hierarchy, $parentName, $nodeName, $prepend)) {
throw new NodeNotFoundException(
"Can't add '$nodeName' node to '$parentName': '$parentName' node not found."
);
}
$this->removeNodeFromList($nodeName);
$this->nodes->set($nodeName, $node);
$this->updateRequired = true;
return $this;
} | [
"protected",
"function",
"add",
"(",
"$",
"parentName",
"=",
"null",
",",
"$",
"nodeName",
",",
"ChildNodeInterface",
"$",
"node",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"addTreeNode",
"(",
"$",
"this",
"->",
"hierarchy",
",",
"$",
"parentName",
",",
"$",
"nodeName",
",",
"$",
"prepend",
")",
")",
"{",
"throw",
"new",
"NodeNotFoundException",
"(",
"\"Can't add '$nodeName' node to '$parentName': '$parentName' node not found.\"",
")",
";",
"}",
"$",
"this",
"->",
"removeNodeFromList",
"(",
"$",
"nodeName",
")",
";",
"$",
"this",
"->",
"nodes",
"->",
"set",
"(",
"$",
"nodeName",
",",
"$",
"node",
")",
";",
"$",
"this",
"->",
"updateRequired",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
]
| Adds new tree node. If node exists, replaces it.
@param string|null $parentName root if null
@param string $nodeName new node name
@param ChildNodeInterface $node
@return $this | [
"Adds",
"new",
"tree",
"node",
".",
"If",
"node",
"exists",
"replaces",
"it",
"."
]
| e73da75f939e207b1c25065e9466c28300e7113c | https://github.com/Nayjest/Tree/blob/e73da75f939e207b1c25065e9466c28300e7113c/src/Tree.php#L271-L283 |
16,342 | axelitus/php-base | src/BigInt.php | BigInt.abs | public static function abs($int)
{
if (!static::is($int)) {
throw new \InvalidArgumentException(
"The \$int parameter must be of type int (or string representing a big int)."
);
}
if (Int::is($int)) {
return Int::abs($int);
} else {
return Str::replace($int, '-', '');
}
} | php | public static function abs($int)
{
if (!static::is($int)) {
throw new \InvalidArgumentException(
"The \$int parameter must be of type int (or string representing a big int)."
);
}
if (Int::is($int)) {
return Int::abs($int);
} else {
return Str::replace($int, '-', '');
}
} | [
"public",
"static",
"function",
"abs",
"(",
"$",
"int",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"int",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$int parameter must be of type int (or string representing a big int).\"",
")",
";",
"}",
"if",
"(",
"Int",
"::",
"is",
"(",
"$",
"int",
")",
")",
"{",
"return",
"Int",
"::",
"abs",
"(",
"$",
"int",
")",
";",
"}",
"else",
"{",
"return",
"Str",
"::",
"replace",
"(",
"$",
"int",
",",
"'-'",
",",
"''",
")",
";",
"}",
"}"
]
| Gets the absolute value of the given integer.
@param int|string $int The number to get the absolute value of.
@return int|string Returns the absolute value of the given integer. | [
"Gets",
"the",
"absolute",
"value",
"of",
"the",
"given",
"integer",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigInt.php#L233-L246 |
16,343 | Teamsisu/contao-mm-frontendInput | src/Teamsisu/MetaModelsFrontendInput/FrontendIntegration/Form/FormURLField.php | FormURLField.validator | protected function validator($varInput)
{
if (is_array($varInput))
{
return parent::validator($varInput);
}
$varInput = \Idna::encodeUrl($varInput);
return parent::validator(trim($varInput));
} | php | protected function validator($varInput)
{
if (is_array($varInput))
{
return parent::validator($varInput);
}
$varInput = \Idna::encodeUrl($varInput);
return parent::validator(trim($varInput));
} | [
"protected",
"function",
"validator",
"(",
"$",
"varInput",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"varInput",
")",
")",
"{",
"return",
"parent",
"::",
"validator",
"(",
"$",
"varInput",
")",
";",
"}",
"$",
"varInput",
"=",
"\\",
"Idna",
"::",
"encodeUrl",
"(",
"$",
"varInput",
")",
";",
"return",
"parent",
"::",
"validator",
"(",
"trim",
"(",
"$",
"varInput",
")",
")",
";",
"}"
]
| Trim the values
@param mixed $varInput The user input
@return mixed The validated user input | [
"Trim",
"the",
"values"
]
| ab92e61c24644f1e61265304b6a35e505007d021 | https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/FrontendIntegration/Form/FormURLField.php#L129-L140 |
16,344 | marmelab/phpcr-api | src/PHPCRAPI/PHPCR/Repository.php | Repository.getRepository | private function getRepository()
{
$c = $this->repository;
if ($c instanceof \Closure) {
$this->repository = $c();
}
return $this->repository;
} | php | private function getRepository()
{
$c = $this->repository;
if ($c instanceof \Closure) {
$this->repository = $c();
}
return $this->repository;
} | [
"private",
"function",
"getRepository",
"(",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"repository",
";",
"if",
"(",
"$",
"c",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"this",
"->",
"repository",
"=",
"$",
"c",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"repository",
";",
"}"
]
| Return the wrapped PHPCR Repository
@return \PHPCR\RepositoryInterface The wrapped repository | [
"Return",
"the",
"wrapped",
"PHPCR",
"Repository"
]
| 372149e27d45babe142d0546894362fce987729b | https://github.com/marmelab/phpcr-api/blob/372149e27d45babe142d0546894362fce987729b/src/PHPCRAPI/PHPCR/Repository.php#L97-L105 |
16,345 | devhelp/piwik-api | src/Param/Segment/Segment.php | Segment.getQuery | public function getQuery()
{
$queryParts = array_map(function ($value) {
return ($value instanceof Operator) ? $value->expression() : $value;
}, $this->queryParts);
return implode('', $queryParts);
} | php | public function getQuery()
{
$queryParts = array_map(function ($value) {
return ($value instanceof Operator) ? $value->expression() : $value;
}, $this->queryParts);
return implode('', $queryParts);
} | [
"public",
"function",
"getQuery",
"(",
")",
"{",
"$",
"queryParts",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"$",
"value",
"instanceof",
"Operator",
")",
"?",
"$",
"value",
"->",
"expression",
"(",
")",
":",
"$",
"value",
";",
"}",
",",
"$",
"this",
"->",
"queryParts",
")",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"queryParts",
")",
";",
"}"
]
| builds the query and returns it as a string
@return string | [
"builds",
"the",
"query",
"and",
"returns",
"it",
"as",
"a",
"string"
]
| b50569fac9736a87be48228d8a336a84418be8da | https://github.com/devhelp/piwik-api/blob/b50569fac9736a87be48228d8a336a84418be8da/src/Param/Segment/Segment.php#L20-L27 |
16,346 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/DateTimePickerOptions.php | DateTimePickerOptions.getDateTimePickerOptions | public function getDateTimePickerOptions()
{
if (! isset($this->dateTimePickerOptions['language']))
$this->dateTimePickerOptions['language'] = config('app.locale');
$available = ['en', 'pl', 'sv', 'de'];
$this->dateTimePickerOptions['language'] =
in_array($this->dateTimePickerOptions['language'], $available)
? $this->dateTimePickerOptions['language'] : 'en';
return $this->dateTimePickerOptions;
} | php | public function getDateTimePickerOptions()
{
if (! isset($this->dateTimePickerOptions['language']))
$this->dateTimePickerOptions['language'] = config('app.locale');
$available = ['en', 'pl', 'sv', 'de'];
$this->dateTimePickerOptions['language'] =
in_array($this->dateTimePickerOptions['language'], $available)
? $this->dateTimePickerOptions['language'] : 'en';
return $this->dateTimePickerOptions;
} | [
"public",
"function",
"getDateTimePickerOptions",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"'language'",
"]",
")",
")",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"'language'",
"]",
"=",
"config",
"(",
"'app.locale'",
")",
";",
"$",
"available",
"=",
"[",
"'en'",
",",
"'pl'",
",",
"'sv'",
",",
"'de'",
"]",
";",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"'language'",
"]",
"=",
"in_array",
"(",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"'language'",
"]",
",",
"$",
"available",
")",
"?",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"'language'",
"]",
":",
"'en'",
";",
"return",
"$",
"this",
"->",
"dateTimePickerOptions",
";",
"}"
]
| Gets the Model datetimepickerOptions.
@return array | [
"Gets",
"the",
"Model",
"datetimepickerOptions",
"."
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/DateTimePickerOptions.php#L29-L40 |
16,347 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/DateTimePickerOptions.php | DateTimePickerOptions.setDateTimePickerOptions | public function setDateTimePickerOptions($attr, $option = null)
{
$options = is_array($attr)
? $attr
: [$attr => $option];
foreach ($options as $key => $value)
$this->dateTimePickerOptions[$key] = $value;
return $this;
} | php | public function setDateTimePickerOptions($attr, $option = null)
{
$options = is_array($attr)
? $attr
: [$attr => $option];
foreach ($options as $key => $value)
$this->dateTimePickerOptions[$key] = $value;
return $this;
} | [
"public",
"function",
"setDateTimePickerOptions",
"(",
"$",
"attr",
",",
"$",
"option",
"=",
"null",
")",
"{",
"$",
"options",
"=",
"is_array",
"(",
"$",
"attr",
")",
"?",
"$",
"attr",
":",
"[",
"$",
"attr",
"=>",
"$",
"option",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"this",
"->",
"dateTimePickerOptions",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the Model datetimepickerOptions.
@param string|array $attr
@param array $option = null
@return self | [
"Sets",
"the",
"Model",
"datetimepickerOptions",
"."
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/DateTimePickerOptions.php#L50-L60 |
16,348 | comelyio/comely | src/Comely/Kernel/Toolkit/Time.php | Time.difference | public static function difference(int $stamp1, int $stamp2 = null): int
{
if (!is_int($stamp2)) {
$stamp2 = time();
}
return $stamp2 > $stamp1 ? $stamp2 - $stamp1 : $stamp1 - $stamp2;
} | php | public static function difference(int $stamp1, int $stamp2 = null): int
{
if (!is_int($stamp2)) {
$stamp2 = time();
}
return $stamp2 > $stamp1 ? $stamp2 - $stamp1 : $stamp1 - $stamp2;
} | [
"public",
"static",
"function",
"difference",
"(",
"int",
"$",
"stamp1",
",",
"int",
"$",
"stamp2",
"=",
"null",
")",
":",
"int",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"stamp2",
")",
")",
"{",
"$",
"stamp2",
"=",
"time",
"(",
")",
";",
"}",
"return",
"$",
"stamp2",
">",
"$",
"stamp1",
"?",
"$",
"stamp2",
"-",
"$",
"stamp1",
":",
"$",
"stamp1",
"-",
"$",
"stamp2",
";",
"}"
]
| Number of seconds elapsed between 2 timestamps
@param int $stamp1
@param int|null $stamp2
@return int | [
"Number",
"of",
"seconds",
"elapsed",
"between",
"2",
"timestamps"
]
| 561ea7aef36fea347a1a79d3ee5597d4057ddf82 | https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/Kernel/Toolkit/Time.php#L30-L37 |
16,349 | tonicospinelli/class-generation | src/ClassGeneration/NamespaceClass.php | NamespaceClass.toString | public function toString()
{
if (!$this->getPath()) {
return '';
}
$path = preg_replace('/^\\\/', '', $this->getPath());
$namespace = $this->getDocBlock()->setTabulation($this->getTabulation())->toString()
. $this->getTabulationFormatted()
. 'namespace '
. $path
. ';' . PHP_EOL;
return $namespace;
} | php | public function toString()
{
if (!$this->getPath()) {
return '';
}
$path = preg_replace('/^\\\/', '', $this->getPath());
$namespace = $this->getDocBlock()->setTabulation($this->getTabulation())->toString()
. $this->getTabulationFormatted()
. 'namespace '
. $path
. ';' . PHP_EOL;
return $namespace;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"path",
"=",
"preg_replace",
"(",
"'/^\\\\\\/'",
",",
"''",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getDocBlock",
"(",
")",
"->",
"setTabulation",
"(",
"$",
"this",
"->",
"getTabulation",
"(",
")",
")",
"->",
"toString",
"(",
")",
".",
"$",
"this",
"->",
"getTabulationFormatted",
"(",
")",
".",
"'namespace '",
".",
"$",
"path",
".",
"';'",
".",
"PHP_EOL",
";",
"return",
"$",
"namespace",
";",
"}"
]
| Parse the namespace string;
@return string | [
"Parse",
"the",
"namespace",
"string",
";"
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/NamespaceClass.php#L124-L139 |
16,350 | kiwiz/ecl | src/Scheduler.php | Scheduler.process | public function process(array $statementlist, SymbolTable $table=null) {
if(is_null($table)) {
$table = new SymbolTable;
}
$statementlist = $this->optimize($statementlist);
$results = [];
// Loop over every Statement and execute it.
foreach($statementlist as $statement) {
$results = array_merge(
$results,
(array) $statement->process($table)
);
}
return $results;
} | php | public function process(array $statementlist, SymbolTable $table=null) {
if(is_null($table)) {
$table = new SymbolTable;
}
$statementlist = $this->optimize($statementlist);
$results = [];
// Loop over every Statement and execute it.
foreach($statementlist as $statement) {
$results = array_merge(
$results,
(array) $statement->process($table)
);
}
return $results;
} | [
"public",
"function",
"process",
"(",
"array",
"$",
"statementlist",
",",
"SymbolTable",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"table",
")",
")",
"{",
"$",
"table",
"=",
"new",
"SymbolTable",
";",
"}",
"$",
"statementlist",
"=",
"$",
"this",
"->",
"optimize",
"(",
"$",
"statementlist",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"// Loop over every Statement and execute it.",
"foreach",
"(",
"$",
"statementlist",
"as",
"$",
"statement",
")",
"{",
"$",
"results",
"=",
"array_merge",
"(",
"$",
"results",
",",
"(",
"array",
")",
"$",
"statement",
"->",
"process",
"(",
"$",
"table",
")",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
]
| Main entrypoint.
@param Statement[] $statementlist A list of Statements for execution.
@return ResultSet[] The list of results. | [
"Main",
"entrypoint",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Scheduler.php#L16-L32 |
16,351 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/Style/StyleDeclaration.php | StyleDeclaration.checkValue | public function checkValue(&$value)
{
if (parent::checkValue($value)) {
$value = trim($value, " \r\n\t\f;");
// Check if declaration contains "!important"
if (strpos($value, "!") !== false) {
$charset = $this->getStyleSheet()->getCharset();
if (mb_strtolower(mb_substr($value, -10, null, $charset), $charset) === "!important") {
$this->setIsImportant(true);
$value = rtrim(mb_substr($value, 0, -10, $charset));
}
}
// Optimize the value
$value = Optimizer::optimizeDeclarationValue($value);
return true;
}
return false;
} | php | public function checkValue(&$value)
{
if (parent::checkValue($value)) {
$value = trim($value, " \r\n\t\f;");
// Check if declaration contains "!important"
if (strpos($value, "!") !== false) {
$charset = $this->getStyleSheet()->getCharset();
if (mb_strtolower(mb_substr($value, -10, null, $charset), $charset) === "!important") {
$this->setIsImportant(true);
$value = rtrim(mb_substr($value, 0, -10, $charset));
}
}
// Optimize the value
$value = Optimizer::optimizeDeclarationValue($value);
return true;
}
return false;
} | [
"public",
"function",
"checkValue",
"(",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"parent",
"::",
"checkValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
",",
"\" \\r\\n\\t\\f;\"",
")",
";",
"// Check if declaration contains \"!important\"",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"\"!\"",
")",
"!==",
"false",
")",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"getStyleSheet",
"(",
")",
"->",
"getCharset",
"(",
")",
";",
"if",
"(",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"value",
",",
"-",
"10",
",",
"null",
",",
"$",
"charset",
")",
",",
"$",
"charset",
")",
"===",
"\"!important\"",
")",
"{",
"$",
"this",
"->",
"setIsImportant",
"(",
"true",
")",
";",
"$",
"value",
"=",
"rtrim",
"(",
"mb_substr",
"(",
"$",
"value",
",",
"0",
",",
"-",
"10",
",",
"$",
"charset",
")",
")",
";",
"}",
"}",
"// Optimize the value",
"$",
"value",
"=",
"Optimizer",
"::",
"optimizeDeclarationValue",
"(",
"$",
"value",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks the value.
@param string $value
@return bool | [
"Checks",
"the",
"value",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/Style/StyleDeclaration.php#L21-L42 |
16,352 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/Style/StyleDeclaration.php | StyleDeclaration.setIsImportant | public function setIsImportant($isImportant)
{
if (is_bool($isImportant)) {
$this->isImportant = $isImportant;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($isImportant). "' for argument 'isImportant' given."
);
}
} | php | public function setIsImportant($isImportant)
{
if (is_bool($isImportant)) {
$this->isImportant = $isImportant;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($isImportant). "' for argument 'isImportant' given."
);
}
} | [
"public",
"function",
"setIsImportant",
"(",
"$",
"isImportant",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"isImportant",
")",
")",
"{",
"$",
"this",
"->",
"isImportant",
"=",
"$",
"isImportant",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"isImportant",
")",
".",
"\"' for argument 'isImportant' given.\"",
")",
";",
"}",
"}"
]
| Sets the importance status of the declaration.
@param $isImportant | [
"Sets",
"the",
"importance",
"status",
"of",
"the",
"declaration",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/Style/StyleDeclaration.php#L49-L58 |
16,353 | sulu/SuluPricingBundle | Controller/PricingController.php | PricingController.postAction | public function postAction(Request $request)
{
try {
$data = $request->request->all();
$this->validatePostData($data);
$locale = $this->getLocale($request);
// Calculate prices for given item
$price = $this->getPriceCalculationManager()->retrieveItemPrices(
$data['items'],
$data['currency'],
$locale
);
$view = $this->view($price, 200);
} catch (PriceCalculationException $pce) {
$view = $this->view($pce->getMessage(), 400);
}
return $this->handleView($view);
} | php | public function postAction(Request $request)
{
try {
$data = $request->request->all();
$this->validatePostData($data);
$locale = $this->getLocale($request);
// Calculate prices for given item
$price = $this->getPriceCalculationManager()->retrieveItemPrices(
$data['items'],
$data['currency'],
$locale
);
$view = $this->view($price, 200);
} catch (PriceCalculationException $pce) {
$view = $this->view($pce->getMessage(), 400);
}
return $this->handleView($view);
} | [
"public",
"function",
"postAction",
"(",
"Request",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
";",
"$",
"this",
"->",
"validatePostData",
"(",
"$",
"data",
")",
";",
"$",
"locale",
"=",
"$",
"this",
"->",
"getLocale",
"(",
"$",
"request",
")",
";",
"// Calculate prices for given item",
"$",
"price",
"=",
"$",
"this",
"->",
"getPriceCalculationManager",
"(",
")",
"->",
"retrieveItemPrices",
"(",
"$",
"data",
"[",
"'items'",
"]",
",",
"$",
"data",
"[",
"'currency'",
"]",
",",
"$",
"locale",
")",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"view",
"(",
"$",
"price",
",",
"200",
")",
";",
"}",
"catch",
"(",
"PriceCalculationException",
"$",
"pce",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"view",
"(",
"$",
"pce",
"->",
"getMessage",
"(",
")",
",",
"400",
")",
";",
"}",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"view",
")",
";",
"}"
]
| Calculates total prices of all given items.
@param Request $request
@return Response | [
"Calculates",
"total",
"prices",
"of",
"all",
"given",
"items",
"."
]
| cd65f823c7c72992d0e423ee758a61f951f1d7d9 | https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Controller/PricingController.php#L32-L52 |
16,354 | sulu/SuluPricingBundle | Controller/PricingController.php | PricingController.validatePostData | private function validatePostData($data)
{
$required = ['items', 'currency'];
foreach ($required as $field) {
if (!isset($data[$field]) && !is_null($data[$field])) {
throw new PriceCalculationException($field . ' is required but not set properly');
}
}
} | php | private function validatePostData($data)
{
$required = ['items', 'currency'];
foreach ($required as $field) {
if (!isset($data[$field]) && !is_null($data[$field])) {
throw new PriceCalculationException($field . ' is required but not set properly');
}
}
} | [
"private",
"function",
"validatePostData",
"(",
"$",
"data",
")",
"{",
"$",
"required",
"=",
"[",
"'items'",
",",
"'currency'",
"]",
";",
"foreach",
"(",
"$",
"required",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"&&",
"!",
"is_null",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
")",
"{",
"throw",
"new",
"PriceCalculationException",
"(",
"$",
"field",
".",
"' is required but not set properly'",
")",
";",
"}",
"}",
"}"
]
| Checks if all necessary data for post request is set.
@param array $data
@throws PriceCalculationException | [
"Checks",
"if",
"all",
"necessary",
"data",
"for",
"post",
"request",
"is",
"set",
"."
]
| cd65f823c7c72992d0e423ee758a61f951f1d7d9 | https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Controller/PricingController.php#L61-L70 |
16,355 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.compile | protected function compile()
{
$attributes = new Attributes();
$this->setLinkTitle($attributes);
$this->setHref($attributes);
$this->setCssClass($attributes);
$this->enableLightbox($attributes);
$this->setDataAttributes($attributes);
// Override the link target
if ($this->target) {
$attributes->setAttribute('target', '_blank');
}
if ($this->bootstrap_icon) {
$this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon);
}
$this->Template->attributes = $attributes;
$this->Template->link = $this->linkTitle;
} | php | protected function compile()
{
$attributes = new Attributes();
$this->setLinkTitle($attributes);
$this->setHref($attributes);
$this->setCssClass($attributes);
$this->enableLightbox($attributes);
$this->setDataAttributes($attributes);
// Override the link target
if ($this->target) {
$attributes->setAttribute('target', '_blank');
}
if ($this->bootstrap_icon) {
$this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon);
}
$this->Template->attributes = $attributes;
$this->Template->link = $this->linkTitle;
} | [
"protected",
"function",
"compile",
"(",
")",
"{",
"$",
"attributes",
"=",
"new",
"Attributes",
"(",
")",
";",
"$",
"this",
"->",
"setLinkTitle",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"setHref",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"setCssClass",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"enableLightbox",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"setDataAttributes",
"(",
"$",
"attributes",
")",
";",
"// Override the link target",
"if",
"(",
"$",
"this",
"->",
"target",
")",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'target'",
",",
"'_blank'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"bootstrap_icon",
")",
"{",
"$",
"this",
"->",
"Template",
"->",
"icon",
"=",
"Bootstrap",
"::",
"generateIcon",
"(",
"$",
"this",
"->",
"bootstrap_icon",
")",
";",
"}",
"$",
"this",
"->",
"Template",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"$",
"this",
"->",
"Template",
"->",
"link",
"=",
"$",
"this",
"->",
"linkTitle",
";",
"}"
]
| Compile button element, inspired by ContentHyperlink.
@return void | [
"Compile",
"button",
"element",
"inspired",
"by",
"ContentHyperlink",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L34-L55 |
16,356 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.setLinkTitle | protected function setLinkTitle(Attributes $attributes)
{
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// See Contao issue: #6258
if (TL_MODE !== 'BE') {
$attributes->setAttribute('title', $this->titleText ?: $this->linkTitle);
}
} | php | protected function setLinkTitle(Attributes $attributes)
{
if ($this->linkTitle == '') {
$this->linkTitle = $this->url;
}
// See Contao issue: #6258
if (TL_MODE !== 'BE') {
$attributes->setAttribute('title', $this->titleText ?: $this->linkTitle);
}
} | [
"protected",
"function",
"setLinkTitle",
"(",
"Attributes",
"$",
"attributes",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"linkTitle",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"linkTitle",
"=",
"$",
"this",
"->",
"url",
";",
"}",
"// See Contao issue: #6258",
"if",
"(",
"TL_MODE",
"!==",
"'BE'",
")",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'title'",
",",
"$",
"this",
"->",
"titleText",
"?",
":",
"$",
"this",
"->",
"linkTitle",
")",
";",
"}",
"}"
]
| Set title link.
@param Attributes $attributes Link attributes.
@return void | [
"Set",
"title",
"link",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L64-L73 |
16,357 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.setHref | protected function setHref(Attributes $attributes)
{
if (substr($this->url, 0, 7) == 'mailto:') {
if (version_compare(VERSION . '.' . BUILD, '3.5.5', '>=')) {
$url = \StringUtil::encodeEmail($this->url);
} else {
$url = \String::encodeEmail($this->url);
}
$attributes->setAttribute('href', $url);
} else {
$attributes->setAttribute('href', ampersand($this->url));
}
} | php | protected function setHref(Attributes $attributes)
{
if (substr($this->url, 0, 7) == 'mailto:') {
if (version_compare(VERSION . '.' . BUILD, '3.5.5', '>=')) {
$url = \StringUtil::encodeEmail($this->url);
} else {
$url = \String::encodeEmail($this->url);
}
$attributes->setAttribute('href', $url);
} else {
$attributes->setAttribute('href', ampersand($this->url));
}
} | [
"protected",
"function",
"setHref",
"(",
"Attributes",
"$",
"attributes",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"this",
"->",
"url",
",",
"0",
",",
"7",
")",
"==",
"'mailto:'",
")",
"{",
"if",
"(",
"version_compare",
"(",
"VERSION",
".",
"'.'",
".",
"BUILD",
",",
"'3.5.5'",
",",
"'>='",
")",
")",
"{",
"$",
"url",
"=",
"\\",
"StringUtil",
"::",
"encodeEmail",
"(",
"$",
"this",
"->",
"url",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"\\",
"String",
"::",
"encodeEmail",
"(",
"$",
"this",
"->",
"url",
")",
";",
"}",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'href'",
",",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'href'",
",",
"ampersand",
"(",
"$",
"this",
"->",
"url",
")",
")",
";",
"}",
"}"
]
| Set Link href.
@param Attributes $attributes Link attributes.
@return void | [
"Set",
"Link",
"href",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L82-L94 |
16,358 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.setCssClass | protected function setCssClass(Attributes $attributes)
{
$attributes->addClass('btn');
if ($this->cssID[1] == '') {
$attributes->addClass('btn-default');
} else {
$attributes->addClass($this->cssID[1]);
}
} | php | protected function setCssClass(Attributes $attributes)
{
$attributes->addClass('btn');
if ($this->cssID[1] == '') {
$attributes->addClass('btn-default');
} else {
$attributes->addClass($this->cssID[1]);
}
} | [
"protected",
"function",
"setCssClass",
"(",
"Attributes",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"'btn'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cssID",
"[",
"1",
"]",
"==",
"''",
")",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"'btn-default'",
")",
";",
"}",
"else",
"{",
"$",
"attributes",
"->",
"addClass",
"(",
"$",
"this",
"->",
"cssID",
"[",
"1",
"]",
")",
";",
"}",
"}"
]
| Set css classes.
@param Attributes $attributes Link attributes.
@return void | [
"Set",
"css",
"classes",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L103-L112 |
16,359 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.enableLightbox | protected function enableLightbox(Attributes $attributes)
{
if (!$this->rel) {
return;
}
if (strncmp($this->rel, 'lightbox', 8) !== 0) {
$attributes->setAttribute('rel', $this->rel);
} else {
$attributes->setAttribute('data-lightbox', substr($this->rel, 9, -1));
}
} | php | protected function enableLightbox(Attributes $attributes)
{
if (!$this->rel) {
return;
}
if (strncmp($this->rel, 'lightbox', 8) !== 0) {
$attributes->setAttribute('rel', $this->rel);
} else {
$attributes->setAttribute('data-lightbox', substr($this->rel, 9, -1));
}
} | [
"protected",
"function",
"enableLightbox",
"(",
"Attributes",
"$",
"attributes",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"rel",
")",
"{",
"return",
";",
"}",
"if",
"(",
"strncmp",
"(",
"$",
"this",
"->",
"rel",
",",
"'lightbox'",
",",
"8",
")",
"!==",
"0",
")",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'rel'",
",",
"$",
"this",
"->",
"rel",
")",
";",
"}",
"else",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'data-lightbox'",
",",
"substr",
"(",
"$",
"this",
"->",
"rel",
",",
"9",
",",
"-",
"1",
")",
")",
";",
"}",
"}"
]
| Enable lightbox.
@param Attributes $attributes Link attributes.
@return void | [
"Enable",
"lightbox",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L121-L132 |
16,360 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php | ButtonElement.setDataAttributes | protected function setDataAttributes(Attributes $attributes)
{
// add data attributes
$this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true);
if (empty($this->bootstrap_dataAttributes)) {
return;
}
foreach ($this->bootstrap_dataAttributes as $attribute) {
if (trim($attribute['value']) != '' && $attribute['name'] != '') {
$attributes->setAttribute('data-' . $attribute['name'], $attribute['value']);
}
}
} | php | protected function setDataAttributes(Attributes $attributes)
{
// add data attributes
$this->bootstrap_dataAttributes = deserialize($this->bootstrap_dataAttributes, true);
if (empty($this->bootstrap_dataAttributes)) {
return;
}
foreach ($this->bootstrap_dataAttributes as $attribute) {
if (trim($attribute['value']) != '' && $attribute['name'] != '') {
$attributes->setAttribute('data-' . $attribute['name'], $attribute['value']);
}
}
} | [
"protected",
"function",
"setDataAttributes",
"(",
"Attributes",
"$",
"attributes",
")",
"{",
"// add data attributes",
"$",
"this",
"->",
"bootstrap_dataAttributes",
"=",
"deserialize",
"(",
"$",
"this",
"->",
"bootstrap_dataAttributes",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"bootstrap_dataAttributes",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"bootstrap_dataAttributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"attribute",
"[",
"'value'",
"]",
")",
"!=",
"''",
"&&",
"$",
"attribute",
"[",
"'name'",
"]",
"!=",
"''",
")",
"{",
"$",
"attributes",
"->",
"setAttribute",
"(",
"'data-'",
".",
"$",
"attribute",
"[",
"'name'",
"]",
",",
"$",
"attribute",
"[",
"'value'",
"]",
")",
";",
"}",
"}",
"}"
]
| Set data attributes.
@param Attributes $attributes Link attributes.
@return void | [
"Set",
"data",
"attributes",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ContentElement/ButtonElement.php#L141-L155 |
16,361 | dumpk/esetres | src/EsetresAWS.php | EsetresAWS.setObjectACL | public static function setObjectACL($key, $bucket, $acl = 'public-read')
{
$s3c = self::getS3C();
if ($s3c->doesObjectExist($bucket, $key)) {
$result = $s3c->putObjectAcl(array(
'ACL' => $acl,
'Bucket' => $bucket,
'Key' => $key,
));
if ($result) {
return true;
}
}
return false;
} | php | public static function setObjectACL($key, $bucket, $acl = 'public-read')
{
$s3c = self::getS3C();
if ($s3c->doesObjectExist($bucket, $key)) {
$result = $s3c->putObjectAcl(array(
'ACL' => $acl,
'Bucket' => $bucket,
'Key' => $key,
));
if ($result) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"setObjectACL",
"(",
"$",
"key",
",",
"$",
"bucket",
",",
"$",
"acl",
"=",
"'public-read'",
")",
"{",
"$",
"s3c",
"=",
"self",
"::",
"getS3C",
"(",
")",
";",
"if",
"(",
"$",
"s3c",
"->",
"doesObjectExist",
"(",
"$",
"bucket",
",",
"$",
"key",
")",
")",
"{",
"$",
"result",
"=",
"$",
"s3c",
"->",
"putObjectAcl",
"(",
"array",
"(",
"'ACL'",
"=>",
"$",
"acl",
",",
"'Bucket'",
"=>",
"$",
"bucket",
",",
"'Key'",
"=>",
"$",
"key",
",",
")",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| setObjectACL
Change the access level of an object on S3.
@param $key
@param $bucket
@param $acl (private|public-read|public-read-write|authenticated-read|bucket-owner-read|bucket-owner-full-control) | [
"setObjectACL",
"Change",
"the",
"access",
"level",
"of",
"an",
"object",
"on",
"S3",
"."
]
| 5ccee3a89e940f2e126e5aaca71a0380c712aa0a | https://github.com/dumpk/esetres/blob/5ccee3a89e940f2e126e5aaca71a0380c712aa0a/src/EsetresAWS.php#L147-L162 |
16,362 | mayoturis/properties-ini | src/VariableProcessor.php | VariableProcessor.getString | public function getString($value) {
if ($this->startsWith($value, '\'') && $this->endsWith($value, '\'')) {
return ltrim(rtrim($value, '\''), '\'');
}
if ($this->startsWith($value, '"') && $this->endsWith($value, '"')) {
return ltrim(rtrim($value, '"'), '"');
}
return $value;
} | php | public function getString($value) {
if ($this->startsWith($value, '\'') && $this->endsWith($value, '\'')) {
return ltrim(rtrim($value, '\''), '\'');
}
if ($this->startsWith($value, '"') && $this->endsWith($value, '"')) {
return ltrim(rtrim($value, '"'), '"');
}
return $value;
} | [
"public",
"function",
"getString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"value",
",",
"'\\''",
")",
"&&",
"$",
"this",
"->",
"endsWith",
"(",
"$",
"value",
",",
"'\\''",
")",
")",
"{",
"return",
"ltrim",
"(",
"rtrim",
"(",
"$",
"value",
",",
"'\\''",
")",
",",
"'\\''",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"value",
",",
"'\"'",
")",
"&&",
"$",
"this",
"->",
"endsWith",
"(",
"$",
"value",
",",
"'\"'",
")",
")",
"{",
"return",
"ltrim",
"(",
"rtrim",
"(",
"$",
"value",
",",
"'\"'",
")",
",",
"'\"'",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Removes ' or " from string
@param string $value
@return string | [
"Removes",
"or",
"from",
"string"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/VariableProcessor.php#L10-L19 |
16,363 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.doIterativeUserSelectionSetup | protected function doIterativeUserSelectionSetup()
{
do {
$modelChoices = $this->getIterativeUserSelectionModeChoices();
if (empty($modelChoices)) return;
$choice = $this->context->command->choice(
"Choose a model to set up Sluggable for",
array_merge($modelChoices, [ 'stop' ])
);
if ($choice == 'stop') return;
if ( ! preg_match('#^(\d+):#', $choice, $matches)) return;
$moduleId = (int) $matches[1];
$candidate = $this->createCandidateArrayForIterativeUserSelection($moduleId);
$this->updateModelDataInteractively($moduleId, $candidate, false);
} while ( ! empty($choice));
} | php | protected function doIterativeUserSelectionSetup()
{
do {
$modelChoices = $this->getIterativeUserSelectionModeChoices();
if (empty($modelChoices)) return;
$choice = $this->context->command->choice(
"Choose a model to set up Sluggable for",
array_merge($modelChoices, [ 'stop' ])
);
if ($choice == 'stop') return;
if ( ! preg_match('#^(\d+):#', $choice, $matches)) return;
$moduleId = (int) $matches[1];
$candidate = $this->createCandidateArrayForIterativeUserSelection($moduleId);
$this->updateModelDataInteractively($moduleId, $candidate, false);
} while ( ! empty($choice));
} | [
"protected",
"function",
"doIterativeUserSelectionSetup",
"(",
")",
"{",
"do",
"{",
"$",
"modelChoices",
"=",
"$",
"this",
"->",
"getIterativeUserSelectionModeChoices",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"modelChoices",
")",
")",
"return",
";",
"$",
"choice",
"=",
"$",
"this",
"->",
"context",
"->",
"command",
"->",
"choice",
"(",
"\"Choose a model to set up Sluggable for\"",
",",
"array_merge",
"(",
"$",
"modelChoices",
",",
"[",
"'stop'",
"]",
")",
")",
";",
"if",
"(",
"$",
"choice",
"==",
"'stop'",
")",
"return",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'#^(\\d+):#'",
",",
"$",
"choice",
",",
"$",
"matches",
")",
")",
"return",
";",
"$",
"moduleId",
"=",
"(",
"int",
")",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"candidate",
"=",
"$",
"this",
"->",
"createCandidateArrayForIterativeUserSelection",
"(",
"$",
"moduleId",
")",
";",
"$",
"this",
"->",
"updateModelDataInteractively",
"(",
"$",
"moduleId",
",",
"$",
"candidate",
",",
"false",
")",
";",
"}",
"while",
"(",
"!",
"empty",
"(",
"$",
"choice",
")",
")",
";",
"}"
]
| Runs through an iterative process wherein the user interactively selects available
models to set up | [
"Runs",
"through",
"an",
"iterative",
"process",
"wherein",
"the",
"user",
"interactively",
"selects",
"available",
"models",
"to",
"set",
"up"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L264-L288 |
16,364 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.getIterativeUserSelectionModeChoices | protected function getIterativeUserSelectionModeChoices()
{
$choices = [];
foreach ($this->context->output['models'] as $id => $model) {
if (in_array($id, $this->modelsDone)) continue;
$choices[] = $id . ': ' . $model['name'];
}
ksort($choices);
return $choices;
} | php | protected function getIterativeUserSelectionModeChoices()
{
$choices = [];
foreach ($this->context->output['models'] as $id => $model) {
if (in_array($id, $this->modelsDone)) continue;
$choices[] = $id . ': ' . $model['name'];
}
ksort($choices);
return $choices;
} | [
"protected",
"function",
"getIterativeUserSelectionModeChoices",
"(",
")",
"{",
"$",
"choices",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"context",
"->",
"output",
"[",
"'models'",
"]",
"as",
"$",
"id",
"=>",
"$",
"model",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"modelsDone",
")",
")",
"continue",
";",
"$",
"choices",
"[",
"]",
"=",
"$",
"id",
".",
"': '",
".",
"$",
"model",
"[",
"'name'",
"]",
";",
"}",
"ksort",
"(",
"$",
"choices",
")",
";",
"return",
"$",
"choices",
";",
"}"
]
| Returns the choices for the iterative user model setup selection process,
leaving out the ones already handled | [
"Returns",
"the",
"choices",
"for",
"the",
"iterative",
"user",
"model",
"setup",
"selection",
"process",
"leaving",
"out",
"the",
"ones",
"already",
"handled"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L294-L307 |
16,365 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.createCandidateArrayForIterativeUserSelection | protected function createCandidateArrayForIterativeUserSelection($moduleId)
{
$candidate = [
'translated' => null,
'slug_column' => null,
'slug_sources_normal' => $this->context->output['models'][ $moduleId ]['normal_attributes'],
'slug_sources_translated' => $this->context->output['models'][ $moduleId ]['translated_attributes'],
];
if ( ! count($candidate['slug_sources_translated'])) {
$candidate['translated'] = false;
} elseif ( ! count($candidate['slug_sources_normal'])) {
$candidate['translated'] = true;
} else {
// ask the user
$candidate['translated'] = $this->context->command->choice(
"Should the slug source be a translated attribute or not?",
[ 'normal model attribute', 'translated attribute' ]
) == 'translated attribute';
}
return $candidate;
} | php | protected function createCandidateArrayForIterativeUserSelection($moduleId)
{
$candidate = [
'translated' => null,
'slug_column' => null,
'slug_sources_normal' => $this->context->output['models'][ $moduleId ]['normal_attributes'],
'slug_sources_translated' => $this->context->output['models'][ $moduleId ]['translated_attributes'],
];
if ( ! count($candidate['slug_sources_translated'])) {
$candidate['translated'] = false;
} elseif ( ! count($candidate['slug_sources_normal'])) {
$candidate['translated'] = true;
} else {
// ask the user
$candidate['translated'] = $this->context->command->choice(
"Should the slug source be a translated attribute or not?",
[ 'normal model attribute', 'translated attribute' ]
) == 'translated attribute';
}
return $candidate;
} | [
"protected",
"function",
"createCandidateArrayForIterativeUserSelection",
"(",
"$",
"moduleId",
")",
"{",
"$",
"candidate",
"=",
"[",
"'translated'",
"=>",
"null",
",",
"'slug_column'",
"=>",
"null",
",",
"'slug_sources_normal'",
"=>",
"$",
"this",
"->",
"context",
"->",
"output",
"[",
"'models'",
"]",
"[",
"$",
"moduleId",
"]",
"[",
"'normal_attributes'",
"]",
",",
"'slug_sources_translated'",
"=>",
"$",
"this",
"->",
"context",
"->",
"output",
"[",
"'models'",
"]",
"[",
"$",
"moduleId",
"]",
"[",
"'translated_attributes'",
"]",
",",
"]",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"candidate",
"[",
"'slug_sources_translated'",
"]",
")",
")",
"{",
"$",
"candidate",
"[",
"'translated'",
"]",
"=",
"false",
";",
"}",
"elseif",
"(",
"!",
"count",
"(",
"$",
"candidate",
"[",
"'slug_sources_normal'",
"]",
")",
")",
"{",
"$",
"candidate",
"[",
"'translated'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"// ask the user",
"$",
"candidate",
"[",
"'translated'",
"]",
"=",
"$",
"this",
"->",
"context",
"->",
"command",
"->",
"choice",
"(",
"\"Should the slug source be a translated attribute or not?\"",
",",
"[",
"'normal model attribute'",
",",
"'translated attribute'",
"]",
")",
"==",
"'translated attribute'",
";",
"}",
"return",
"$",
"candidate",
";",
"}"
]
| Creates candidate array for handling sluggable interactive process for the user selection approach
@param int $moduleId
@return array | [
"Creates",
"candidate",
"array",
"for",
"handling",
"sluggable",
"interactive",
"process",
"for",
"the",
"user",
"selection",
"approach"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L315-L341 |
16,366 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.findSluggableCandidateModels | protected function findSluggableCandidateModels()
{
$candidates = [];
foreach ($this->context->output['models'] as $model) {
if ($this->isExcludedSluggable($model['module'])) continue;
if ($result = $this->applyOverrideForSluggable($model)) {
$candidates[ $model['module'] ] = $result;
continue;
}
if ($result = $this->analyzeModelForSluggable($model)) {
$candidates[ $model['module'] ] = $result;
}
}
return $candidates;
} | php | protected function findSluggableCandidateModels()
{
$candidates = [];
foreach ($this->context->output['models'] as $model) {
if ($this->isExcludedSluggable($model['module'])) continue;
if ($result = $this->applyOverrideForSluggable($model)) {
$candidates[ $model['module'] ] = $result;
continue;
}
if ($result = $this->analyzeModelForSluggable($model)) {
$candidates[ $model['module'] ] = $result;
}
}
return $candidates;
} | [
"protected",
"function",
"findSluggableCandidateModels",
"(",
")",
"{",
"$",
"candidates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"context",
"->",
"output",
"[",
"'models'",
"]",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExcludedSluggable",
"(",
"$",
"model",
"[",
"'module'",
"]",
")",
")",
"continue",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"applyOverrideForSluggable",
"(",
"$",
"model",
")",
")",
"{",
"$",
"candidates",
"[",
"$",
"model",
"[",
"'module'",
"]",
"]",
"=",
"$",
"result",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"analyzeModelForSluggable",
"(",
"$",
"model",
")",
")",
"{",
"$",
"candidates",
"[",
"$",
"model",
"[",
"'module'",
"]",
"]",
"=",
"$",
"result",
";",
"}",
"}",
"return",
"$",
"candidates",
";",
"}"
]
| Finds all the models that the user might want to make sluggable
@return array | [
"Finds",
"all",
"the",
"models",
"that",
"the",
"user",
"might",
"want",
"to",
"make",
"sluggable"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L348-L369 |
16,367 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.applyOverrideForSluggable | protected function applyOverrideForSluggable(array $model)
{
if ( ! array_key_exists($model['module'], $this->overrides)) {
return false;
}
$override = $this->overrides[ $model['module'] ];
$analysis = [
'translated' => false,
'slug_column' => null,
'slug_sources_normal' => [],
'slug_sources_translated' => [],
];
// set the source attribute (determine whether it is available and/or translatable)
if ( ! array_key_exists('source', $override)) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. No source.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
if (in_array($override['source'], $model['normal_attributes'])) {
$analysis['slug_sources_normal'] = [ $override['source'] ];
} elseif (in_array($override['source'], $model['translated_attributes'])) {
$analysis['slug_sources_translated'] = [ $override['source'] ];
} else {
// couldn't find the attribute
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Source attribute '{$override['source']}' does not exist.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
// if provided, check and set the slug target attribute (on the model itself)
if (isset($override['slug'])) {
if ($override['slug'] == $override['source']) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Slug attribute '{$override['slug']}' is same as source attribute.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
if (in_array($override['slug'], $model['normal_attributes'])) {
$analysis['translated'] = false;
} elseif (in_array($override['slug'], $model['translated_attributes'])) {
$analysis['translated'] = true;
} else {
// couldn't find the attribute
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Slug attribute '{$override['slug']}' does not exist.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
$analysis['slug_column'] = $override['slug'];
// if source is translated, slug must be, and vice versa!
if ( $analysis['translated'] && count($analysis['slug_sources_normal'])
|| ! $analysis['translated'] && count($analysis['slug_sources_translated'])
) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Either Slug and Source attribute must be translated, or neither.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
}
// ensure that translated is set if source is translated
$analysis['translated'] = (count($analysis['slug_sources_translated']) > 0);
return $analysis;
} | php | protected function applyOverrideForSluggable(array $model)
{
if ( ! array_key_exists($model['module'], $this->overrides)) {
return false;
}
$override = $this->overrides[ $model['module'] ];
$analysis = [
'translated' => false,
'slug_column' => null,
'slug_sources_normal' => [],
'slug_sources_translated' => [],
];
// set the source attribute (determine whether it is available and/or translatable)
if ( ! array_key_exists('source', $override)) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. No source.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
if (in_array($override['source'], $model['normal_attributes'])) {
$analysis['slug_sources_normal'] = [ $override['source'] ];
} elseif (in_array($override['source'], $model['translated_attributes'])) {
$analysis['slug_sources_translated'] = [ $override['source'] ];
} else {
// couldn't find the attribute
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Source attribute '{$override['source']}' does not exist.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
// if provided, check and set the slug target attribute (on the model itself)
if (isset($override['slug'])) {
if ($override['slug'] == $override['source']) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Slug attribute '{$override['slug']}' is same as source attribute.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
if (in_array($override['slug'], $model['normal_attributes'])) {
$analysis['translated'] = false;
} elseif (in_array($override['slug'], $model['translated_attributes'])) {
$analysis['translated'] = true;
} else {
// couldn't find the attribute
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Slug attribute '{$override['slug']}' does not exist.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
$analysis['slug_column'] = $override['slug'];
// if source is translated, slug must be, and vice versa!
if ( $analysis['translated'] && count($analysis['slug_sources_normal'])
|| ! $analysis['translated'] && count($analysis['slug_sources_translated'])
) {
$this->context->log(
"Invalid slugs override configuration for model #{$model['module']}. "
. "Either Slug and Source attribute must be translated, or neither.",
Generator::LOG_LEVEL_ERROR
);
return false;
}
}
// ensure that translated is set if source is translated
$analysis['translated'] = (count($analysis['slug_sources_translated']) > 0);
return $analysis;
} | [
"protected",
"function",
"applyOverrideForSluggable",
"(",
"array",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"model",
"[",
"'module'",
"]",
",",
"$",
"this",
"->",
"overrides",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"override",
"=",
"$",
"this",
"->",
"overrides",
"[",
"$",
"model",
"[",
"'module'",
"]",
"]",
";",
"$",
"analysis",
"=",
"[",
"'translated'",
"=>",
"false",
",",
"'slug_column'",
"=>",
"null",
",",
"'slug_sources_normal'",
"=>",
"[",
"]",
",",
"'slug_sources_translated'",
"=>",
"[",
"]",
",",
"]",
";",
"// set the source attribute (determine whether it is available and/or translatable)",
"if",
"(",
"!",
"array_key_exists",
"(",
"'source'",
",",
"$",
"override",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Invalid slugs override configuration for model #{$model['module']}. No source.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"override",
"[",
"'source'",
"]",
",",
"$",
"model",
"[",
"'normal_attributes'",
"]",
")",
")",
"{",
"$",
"analysis",
"[",
"'slug_sources_normal'",
"]",
"=",
"[",
"$",
"override",
"[",
"'source'",
"]",
"]",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"override",
"[",
"'source'",
"]",
",",
"$",
"model",
"[",
"'translated_attributes'",
"]",
")",
")",
"{",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
"=",
"[",
"$",
"override",
"[",
"'source'",
"]",
"]",
";",
"}",
"else",
"{",
"// couldn't find the attribute",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Invalid slugs override configuration for model #{$model['module']}. \"",
".",
"\"Source attribute '{$override['source']}' does not exist.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"return",
"false",
";",
"}",
"// if provided, check and set the slug target attribute (on the model itself)",
"if",
"(",
"isset",
"(",
"$",
"override",
"[",
"'slug'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"override",
"[",
"'slug'",
"]",
"==",
"$",
"override",
"[",
"'source'",
"]",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Invalid slugs override configuration for model #{$model['module']}. \"",
".",
"\"Slug attribute '{$override['slug']}' is same as source attribute.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"override",
"[",
"'slug'",
"]",
",",
"$",
"model",
"[",
"'normal_attributes'",
"]",
")",
")",
"{",
"$",
"analysis",
"[",
"'translated'",
"]",
"=",
"false",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"override",
"[",
"'slug'",
"]",
",",
"$",
"model",
"[",
"'translated_attributes'",
"]",
")",
")",
"{",
"$",
"analysis",
"[",
"'translated'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"// couldn't find the attribute",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Invalid slugs override configuration for model #{$model['module']}. \"",
".",
"\"Slug attribute '{$override['slug']}' does not exist.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"return",
"false",
";",
"}",
"$",
"analysis",
"[",
"'slug_column'",
"]",
"=",
"$",
"override",
"[",
"'slug'",
"]",
";",
"// if source is translated, slug must be, and vice versa!",
"if",
"(",
"$",
"analysis",
"[",
"'translated'",
"]",
"&&",
"count",
"(",
"$",
"analysis",
"[",
"'slug_sources_normal'",
"]",
")",
"||",
"!",
"$",
"analysis",
"[",
"'translated'",
"]",
"&&",
"count",
"(",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Invalid slugs override configuration for model #{$model['module']}. \"",
".",
"\"Either Slug and Source attribute must be translated, or neither.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"return",
"false",
";",
"}",
"}",
"// ensure that translated is set if source is translated",
"$",
"analysis",
"[",
"'translated'",
"]",
"=",
"(",
"count",
"(",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
")",
">",
"0",
")",
";",
"return",
"$",
"analysis",
";",
"}"
]
| Returns overridden analysis result for model
after checking it against the model's data
@param array $model
@return array|false | [
"Returns",
"overridden",
"analysis",
"result",
"for",
"model",
"after",
"checking",
"it",
"against",
"the",
"model",
"s",
"data"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L380-L472 |
16,368 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php | AnalyzeSluggableInteractive.analyzeModelForSluggable | protected function analyzeModelForSluggable(array $model)
{
$analysis = [
'translated' => null,
'slug_column' => null,
'slug_sources_normal' => [],
'slug_sources_translated' => [],
];
// find out whether the model has a 'slug' column, preferring the first match we find
$slugColumns = config('pxlcms.generator.models.slugs.slug_columns', []);
foreach ($slugColumns as $slugColumn) {
foreach ($model['normal_attributes'] as $attribute) {
if ($attribute == $slugColumn) {
$analysis['slug_column'] = $attribute;
$analysis['translated'] = false;
break 2;
}
}
foreach ($model['translated_attributes'] as $attribute) {
if ($attribute == $slugColumn) {
$analysis['slug_column'] = $attribute;
$analysis['translated'] = true;
break 2;
}
}
}
// discard any matches that don't have a slug column on the model
// if there is no slug structure present (because that could never work)
if ( ! $this->context->slugStructurePresent && empty($analysis['slug_column'])) return false;
// find out whether the model has slug source candidate columns
$slugSources = config('pxlcms.generator.models.slugs.slug_source_columns', []);
// make sure we keep slug and source column in the same model (translated or parent)
$analysis['slug_sources_translated'] = array_values(array_intersect($slugSources, $model['translated_attributes']));
$analysis['slug_sources_normal'] = array_values(array_intersect($slugSources, $model['normal_attributes']));
if ($analysis['translated'] === true) {
$analysis['slug_sources_normal'] = [];
} elseif ($analysis === false) {
$analysis['slug_sources_translated'] = [];
}
// any matches? return as candidate
if ( ! empty($analysis['slug_column'])
|| count($analysis['slug_sources_normal'])
|| count($analysis['slug_sources_translated'])
) {
return $analysis;
}
return false;
} | php | protected function analyzeModelForSluggable(array $model)
{
$analysis = [
'translated' => null,
'slug_column' => null,
'slug_sources_normal' => [],
'slug_sources_translated' => [],
];
// find out whether the model has a 'slug' column, preferring the first match we find
$slugColumns = config('pxlcms.generator.models.slugs.slug_columns', []);
foreach ($slugColumns as $slugColumn) {
foreach ($model['normal_attributes'] as $attribute) {
if ($attribute == $slugColumn) {
$analysis['slug_column'] = $attribute;
$analysis['translated'] = false;
break 2;
}
}
foreach ($model['translated_attributes'] as $attribute) {
if ($attribute == $slugColumn) {
$analysis['slug_column'] = $attribute;
$analysis['translated'] = true;
break 2;
}
}
}
// discard any matches that don't have a slug column on the model
// if there is no slug structure present (because that could never work)
if ( ! $this->context->slugStructurePresent && empty($analysis['slug_column'])) return false;
// find out whether the model has slug source candidate columns
$slugSources = config('pxlcms.generator.models.slugs.slug_source_columns', []);
// make sure we keep slug and source column in the same model (translated or parent)
$analysis['slug_sources_translated'] = array_values(array_intersect($slugSources, $model['translated_attributes']));
$analysis['slug_sources_normal'] = array_values(array_intersect($slugSources, $model['normal_attributes']));
if ($analysis['translated'] === true) {
$analysis['slug_sources_normal'] = [];
} elseif ($analysis === false) {
$analysis['slug_sources_translated'] = [];
}
// any matches? return as candidate
if ( ! empty($analysis['slug_column'])
|| count($analysis['slug_sources_normal'])
|| count($analysis['slug_sources_translated'])
) {
return $analysis;
}
return false;
} | [
"protected",
"function",
"analyzeModelForSluggable",
"(",
"array",
"$",
"model",
")",
"{",
"$",
"analysis",
"=",
"[",
"'translated'",
"=>",
"null",
",",
"'slug_column'",
"=>",
"null",
",",
"'slug_sources_normal'",
"=>",
"[",
"]",
",",
"'slug_sources_translated'",
"=>",
"[",
"]",
",",
"]",
";",
"// find out whether the model has a 'slug' column, preferring the first match we find",
"$",
"slugColumns",
"=",
"config",
"(",
"'pxlcms.generator.models.slugs.slug_columns'",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"slugColumns",
"as",
"$",
"slugColumn",
")",
"{",
"foreach",
"(",
"$",
"model",
"[",
"'normal_attributes'",
"]",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"attribute",
"==",
"$",
"slugColumn",
")",
"{",
"$",
"analysis",
"[",
"'slug_column'",
"]",
"=",
"$",
"attribute",
";",
"$",
"analysis",
"[",
"'translated'",
"]",
"=",
"false",
";",
"break",
"2",
";",
"}",
"}",
"foreach",
"(",
"$",
"model",
"[",
"'translated_attributes'",
"]",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"attribute",
"==",
"$",
"slugColumn",
")",
"{",
"$",
"analysis",
"[",
"'slug_column'",
"]",
"=",
"$",
"attribute",
";",
"$",
"analysis",
"[",
"'translated'",
"]",
"=",
"true",
";",
"break",
"2",
";",
"}",
"}",
"}",
"// discard any matches that don't have a slug column on the model",
"// if there is no slug structure present (because that could never work)",
"if",
"(",
"!",
"$",
"this",
"->",
"context",
"->",
"slugStructurePresent",
"&&",
"empty",
"(",
"$",
"analysis",
"[",
"'slug_column'",
"]",
")",
")",
"return",
"false",
";",
"// find out whether the model has slug source candidate columns",
"$",
"slugSources",
"=",
"config",
"(",
"'pxlcms.generator.models.slugs.slug_source_columns'",
",",
"[",
"]",
")",
";",
"// make sure we keep slug and source column in the same model (translated or parent)",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
"=",
"array_values",
"(",
"array_intersect",
"(",
"$",
"slugSources",
",",
"$",
"model",
"[",
"'translated_attributes'",
"]",
")",
")",
";",
"$",
"analysis",
"[",
"'slug_sources_normal'",
"]",
"=",
"array_values",
"(",
"array_intersect",
"(",
"$",
"slugSources",
",",
"$",
"model",
"[",
"'normal_attributes'",
"]",
")",
")",
";",
"if",
"(",
"$",
"analysis",
"[",
"'translated'",
"]",
"===",
"true",
")",
"{",
"$",
"analysis",
"[",
"'slug_sources_normal'",
"]",
"=",
"[",
"]",
";",
"}",
"elseif",
"(",
"$",
"analysis",
"===",
"false",
")",
"{",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
"=",
"[",
"]",
";",
"}",
"// any matches? return as candidate",
"if",
"(",
"!",
"empty",
"(",
"$",
"analysis",
"[",
"'slug_column'",
"]",
")",
"||",
"count",
"(",
"$",
"analysis",
"[",
"'slug_sources_normal'",
"]",
")",
"||",
"count",
"(",
"$",
"analysis",
"[",
"'slug_sources_translated'",
"]",
")",
")",
"{",
"return",
"$",
"analysis",
";",
"}",
"return",
"false",
";",
"}"
]
| Determines whether the model data makes it a sluggable candidate
and returns analysis result
@param array $model model data
@return array|false false if not a candidate | [
"Determines",
"whether",
"the",
"model",
"data",
"makes",
"it",
"a",
"sluggable",
"candidate",
"and",
"returns",
"analysis",
"result"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeSluggableInteractive.php#L481-L539 |
16,369 | activecollab/databasestructure | src/Type.php | Type.& | public function &setBaseClassExtends($class_name)
{
if ($class_name && class_exists($class_name) && (new \ReflectionClass($class_name))->isSubclassOf(Entity::class)) {
} else {
throw new InvalidArgumentException("Class name '$class_name' is not valid");
}
$this->base_class_extends = $class_name;
return $this;
} | php | public function &setBaseClassExtends($class_name)
{
if ($class_name && class_exists($class_name) && (new \ReflectionClass($class_name))->isSubclassOf(Entity::class)) {
} else {
throw new InvalidArgumentException("Class name '$class_name' is not valid");
}
$this->base_class_extends = $class_name;
return $this;
} | [
"public",
"function",
"&",
"setBaseClassExtends",
"(",
"$",
"class_name",
")",
"{",
"if",
"(",
"$",
"class_name",
"&&",
"class_exists",
"(",
"$",
"class_name",
")",
"&&",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class_name",
")",
")",
"->",
"isSubclassOf",
"(",
"Entity",
"::",
"class",
")",
")",
"{",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Class name '$class_name' is not valid\"",
")",
";",
"}",
"$",
"this",
"->",
"base_class_extends",
"=",
"$",
"class_name",
";",
"return",
"$",
"this",
";",
"}"
]
| Set name of a class that base type class should extend.
Note: This class needs to descened from Object class of DatabaseObject package
@param string $class_name
@return $this | [
"Set",
"name",
"of",
"a",
"class",
"that",
"base",
"type",
"class",
"should",
"extend",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L248-L258 |
16,370 | activecollab/databasestructure | src/Type.php | Type.getIdField | public function getIdField()
{
if (empty($this->id_field)) {
$this->id_field = (new IntegerField('id', 0))->unsigned(true)->size($this->getExpectedDatasetSize());
}
return $this->id_field;
} | php | public function getIdField()
{
if (empty($this->id_field)) {
$this->id_field = (new IntegerField('id', 0))->unsigned(true)->size($this->getExpectedDatasetSize());
}
return $this->id_field;
} | [
"public",
"function",
"getIdField",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"id_field",
")",
")",
"{",
"$",
"this",
"->",
"id_field",
"=",
"(",
"new",
"IntegerField",
"(",
"'id'",
",",
"0",
")",
")",
"->",
"unsigned",
"(",
"true",
")",
"->",
"size",
"(",
"$",
"this",
"->",
"getExpectedDatasetSize",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"id_field",
";",
"}"
]
| Return ID field for this type.
@return IntegerField | [
"Return",
"ID",
"field",
"for",
"this",
"type",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L314-L321 |
16,371 | activecollab/databasestructure | src/Type.php | Type.& | public function &addField(FieldInterface $field)
{
if (empty($this->fields[$field->getName()])) {
$this->fields[$field->getName()] = $field;
$field->onAddedToType($this); // Let the field register indexes, custom behaviour etc
} else {
throw new InvalidArgumentException("Field '" . $field->getName() . "' already exists in this type");
}
return $this;
} | php | public function &addField(FieldInterface $field)
{
if (empty($this->fields[$field->getName()])) {
$this->fields[$field->getName()] = $field;
$field->onAddedToType($this); // Let the field register indexes, custom behaviour etc
} else {
throw new InvalidArgumentException("Field '" . $field->getName() . "' already exists in this type");
}
return $this;
} | [
"public",
"function",
"&",
"addField",
"(",
"FieldInterface",
"$",
"field",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"field",
";",
"$",
"field",
"->",
"onAddedToType",
"(",
"$",
"this",
")",
";",
"// Let the field register indexes, custom behaviour etc",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field '\"",
".",
"$",
"field",
"->",
"getName",
"(",
")",
".",
"\"' already exists in this type\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a single field to the type.
@param FieldInterface $field
@return $this | [
"Add",
"a",
"single",
"field",
"to",
"the",
"type",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L363-L373 |
16,372 | activecollab/databasestructure | src/Type.php | Type.getAllIndexes | public function getAllIndexes()
{
$result = [new Index('id', ['id'], IndexInterface::PRIMARY)];
if ($this->getPolymorph()) {
$result[] = new Index('type');
}
if (!empty($this->getIndexes())) {
$result = array_merge($result, $this->getIndexes());
}
foreach ($this->getAssociations() as $assosication) {
if ($assosication instanceof InjectIndexesInsterface) {
$association_indexes = $assosication->getIndexes();
if (!empty($association_indexes)) {
$result = array_merge($result, $association_indexes);
}
}
}
return $result;
} | php | public function getAllIndexes()
{
$result = [new Index('id', ['id'], IndexInterface::PRIMARY)];
if ($this->getPolymorph()) {
$result[] = new Index('type');
}
if (!empty($this->getIndexes())) {
$result = array_merge($result, $this->getIndexes());
}
foreach ($this->getAssociations() as $assosication) {
if ($assosication instanceof InjectIndexesInsterface) {
$association_indexes = $assosication->getIndexes();
if (!empty($association_indexes)) {
$result = array_merge($result, $association_indexes);
}
}
}
return $result;
} | [
"public",
"function",
"getAllIndexes",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"new",
"Index",
"(",
"'id'",
",",
"[",
"'id'",
"]",
",",
"IndexInterface",
"::",
"PRIMARY",
")",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"getPolymorph",
"(",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"new",
"Index",
"(",
"'type'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getIndexes",
"(",
")",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"getIndexes",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getAssociations",
"(",
")",
"as",
"$",
"assosication",
")",
"{",
"if",
"(",
"$",
"assosication",
"instanceof",
"InjectIndexesInsterface",
")",
"{",
"$",
"association_indexes",
"=",
"$",
"assosication",
"->",
"getIndexes",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"association_indexes",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"association_indexes",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Return all indexes.
@return IndexInterface[] | [
"Return",
"all",
"indexes",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L480-L503 |
16,373 | activecollab/databasestructure | src/Type.php | Type.& | public function &orderBy($order_by)
{
if (empty($order_by)) {
throw new InvalidArgumentException('Order by value is required');
} elseif (!is_string($order_by) && !is_array($order_by)) {
throw new InvalidArgumentException('Order by can be string or array');
}
$this->order_by = (array) $order_by;
return $this;
} | php | public function &orderBy($order_by)
{
if (empty($order_by)) {
throw new InvalidArgumentException('Order by value is required');
} elseif (!is_string($order_by) && !is_array($order_by)) {
throw new InvalidArgumentException('Order by can be string or array');
}
$this->order_by = (array) $order_by;
return $this;
} | [
"public",
"function",
"&",
"orderBy",
"(",
"$",
"order_by",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"order_by",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Order by value is required'",
")",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"order_by",
")",
"&&",
"!",
"is_array",
"(",
"$",
"order_by",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Order by can be string or array'",
")",
";",
"}",
"$",
"this",
"->",
"order_by",
"=",
"(",
"array",
")",
"$",
"order_by",
";",
"return",
"$",
"this",
";",
"}"
]
| Set how records of this type should be ordered by default.
@param string|array $order_by
@return $this | [
"Set",
"how",
"records",
"of",
"this",
"type",
"should",
"be",
"ordered",
"by",
"default",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L735-L746 |
16,374 | activecollab/databasestructure | src/Type.php | Type.& | public function &serialize(...$fields)
{
if (!empty($fields)) {
$this->serialize = array_unique(array_merge($this->serialize, $fields));
}
return $this;
} | php | public function &serialize(...$fields)
{
if (!empty($fields)) {
$this->serialize = array_unique(array_merge($this->serialize, $fields));
}
return $this;
} | [
"public",
"function",
"&",
"serialize",
"(",
"...",
"$",
"fields",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"this",
"->",
"serialize",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"serialize",
",",
"$",
"fields",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set a list of fields that will be included during object serialization.
@param string[] $fields
@return $this | [
"Set",
"a",
"list",
"of",
"fields",
"that",
"will",
"be",
"included",
"during",
"object",
"serialization",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Type.php#L769-L776 |
16,375 | hrevert/HtUserRegistration | src/Service/UserRegistrationService.php | UserRegistrationService.createRegistrationRecord | protected function createRegistrationRecord(UserInterface $user)
{
$entityClass = $this->getOptions()->getRegistrationEntityClass();
$entity = new $entityClass($user);
$this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'record' => $entity));
$entity->generateToken();
$this->getUserRegistrationMapper()->insert($entity);
$this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array('user' => $user, 'record' => $entity));
return $entity;
} | php | protected function createRegistrationRecord(UserInterface $user)
{
$entityClass = $this->getOptions()->getRegistrationEntityClass();
$entity = new $entityClass($user);
$this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'record' => $entity));
$entity->generateToken();
$this->getUserRegistrationMapper()->insert($entity);
$this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, array('user' => $user, 'record' => $entity));
return $entity;
} | [
"protected",
"function",
"createRegistrationRecord",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"entityClass",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getRegistrationEntityClass",
"(",
")",
";",
"$",
"entity",
"=",
"new",
"$",
"entityClass",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"__FUNCTION__",
",",
"$",
"this",
",",
"array",
"(",
"'user'",
"=>",
"$",
"user",
",",
"'record'",
"=>",
"$",
"entity",
")",
")",
";",
"$",
"entity",
"->",
"generateToken",
"(",
")",
";",
"$",
"this",
"->",
"getUserRegistrationMapper",
"(",
")",
"->",
"insert",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"__FUNCTION__",
".",
"'.post'",
",",
"$",
"this",
",",
"array",
"(",
"'user'",
"=>",
"$",
"user",
",",
"'record'",
"=>",
"$",
"entity",
")",
")",
";",
"return",
"$",
"entity",
";",
"}"
]
| Stored user registration record to database
@return UserInterface $user
@return UserRegistrationInterface | [
"Stored",
"user",
"registration",
"record",
"to",
"database"
]
| 6b4a0cc364153757290ab5eed9ffafe1228f3bd6 | https://github.com/hrevert/HtUserRegistration/blob/6b4a0cc364153757290ab5eed9ffafe1228f3bd6/src/Service/UserRegistrationService.php#L107-L117 |
16,376 | syhol/mrcolor | src/SyHolloway/MrColor/Extension.php | Extension.trigger | public function trigger(Color $color, $method, $args)
{
if (is_callable(array($this, $method))) {
array_unshift($args, $color);
return call_user_func_array(array($this, $method), $args);
}
return null;
} | php | public function trigger(Color $color, $method, $args)
{
if (is_callable(array($this, $method))) {
array_unshift($args, $color);
return call_user_func_array(array($this, $method), $args);
}
return null;
} | [
"public",
"function",
"trigger",
"(",
"Color",
"$",
"color",
",",
"$",
"method",
",",
"$",
"args",
")",
"{",
"if",
"(",
"is_callable",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"color",
")",
";",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"args",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Handel the method call.
@param Color $color the color object the function was called on
@param string $method the method name
@param array $args arguments
@return mixed this will be returned to the client code | [
"Handel",
"the",
"method",
"call",
"."
]
| b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d | https://github.com/syhol/mrcolor/blob/b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d/src/SyHolloway/MrColor/Extension.php#L33-L42 |
16,377 | zrcing/phpenv | src/Phpenv/Env.php | Env.overload | public static function overload($envFile = ".env")
{
self::getLoader()->overloader = true;
self::getLoader()->innerLoad($envFile);
} | php | public static function overload($envFile = ".env")
{
self::getLoader()->overloader = true;
self::getLoader()->innerLoad($envFile);
} | [
"public",
"static",
"function",
"overload",
"(",
"$",
"envFile",
"=",
"\".env\"",
")",
"{",
"self",
"::",
"getLoader",
"(",
")",
"->",
"overloader",
"=",
"true",
";",
"self",
"::",
"getLoader",
"(",
")",
"->",
"innerLoad",
"(",
"$",
"envFile",
")",
";",
"}"
]
| Overload environment config
@param string $envFile Absolute path | [
"Overload",
"environment",
"config"
]
| a2f8a5d88c92f0db99887f7501cb6274833d6d0b | https://github.com/zrcing/phpenv/blob/a2f8a5d88c92f0db99887f7501cb6274833d6d0b/src/Phpenv/Env.php#L48-L52 |
16,378 | comelyio/comely | src/Comely/IO/Cache/Indexing.php | Indexing.load | public function load(): void
{
try {
$keys = $this->cache->get(self::INDEXING_KEY);
if ($keys instanceof Keys) {
$this->keys = $keys;
return;
}
} catch (CacheException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
}
$this->keys = new Keys();
} | php | public function load(): void
{
try {
$keys = $this->cache->get(self::INDEXING_KEY);
if ($keys instanceof Keys) {
$this->keys = $keys;
return;
}
} catch (CacheException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
}
$this->keys = new Keys();
} | [
"public",
"function",
"load",
"(",
")",
":",
"void",
"{",
"try",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"INDEXING_KEY",
")",
";",
"if",
"(",
"$",
"keys",
"instanceof",
"Keys",
")",
"{",
"$",
"this",
"->",
"keys",
"=",
"$",
"keys",
";",
"return",
";",
"}",
"}",
"catch",
"(",
"CacheException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"E_USER_WARNING",
")",
";",
"}",
"$",
"this",
"->",
"keys",
"=",
"new",
"Keys",
"(",
")",
";",
"}"
]
| Load stored keys from Cache or create new index | [
"Load",
"stored",
"keys",
"from",
"Cache",
"or",
"create",
"new",
"index"
]
| 561ea7aef36fea347a1a79d3ee5597d4057ddf82 | https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Cache/Indexing.php#L61-L74 |
16,379 | harp-orm/query | src/Compiler/Direction.php | Direction.render | public static function render(SQL\Direction $item)
{
return Compiler::expression(array(
Compiler::name($item->getContent()),
$item->getDirection(),
));
} | php | public static function render(SQL\Direction $item)
{
return Compiler::expression(array(
Compiler::name($item->getContent()),
$item->getDirection(),
));
} | [
"public",
"static",
"function",
"render",
"(",
"SQL",
"\\",
"Direction",
"$",
"item",
")",
"{",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"Compiler",
"::",
"name",
"(",
"$",
"item",
"->",
"getContent",
"(",
")",
")",
",",
"$",
"item",
"->",
"getDirection",
"(",
")",
",",
")",
")",
";",
"}"
]
| Render a Direction object
@param SQL\Direction $item
@return string | [
"Render",
"a",
"Direction",
"object"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Direction.php#L32-L38 |
16,380 | pageon/SlackWebhookMonolog | src/Slack/Attachment/BasicInfoAttachment.php | BasicInfoAttachment.addRecordDataAsJsonEncodedField | private function addRecordDataAsJsonEncodedField($key, $label)
{
if (!empty($this->record[$key])) {
$this->addField(new Field($label, json_encode($this->record[$key])));
}
} | php | private function addRecordDataAsJsonEncodedField($key, $label)
{
if (!empty($this->record[$key])) {
$this->addField(new Field($label, json_encode($this->record[$key])));
}
} | [
"private",
"function",
"addRecordDataAsJsonEncodedField",
"(",
"$",
"key",
",",
"$",
"label",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"record",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addField",
"(",
"new",
"Field",
"(",
"$",
"label",
",",
"json_encode",
"(",
"$",
"this",
"->",
"record",
"[",
"$",
"key",
"]",
")",
")",
")",
";",
"}",
"}"
]
| Check if a key is available in the record. If so, add it as a field.
@param string $key
@param string $label | [
"Check",
"if",
"a",
"key",
"is",
"available",
"in",
"the",
"record",
".",
"If",
"so",
"add",
"it",
"as",
"a",
"field",
"."
]
| 6755060ddd6429620fd4c7decbb95f05463fc36b | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/BasicInfoAttachment.php#L64-L69 |
16,381 | nicolasmure/NmureEncryptor | src/Encryptor.php | Encryptor.turnHexKeyToBin | public function turnHexKeyToBin()
{
if (!ctype_xdigit($this->secret)) {
throw new InvalidSecretKeyException(sprintf('The secret key "%s" is not a hex key', $this->secret));
}
$this->secret = hex2bin($this->secret);
} | php | public function turnHexKeyToBin()
{
if (!ctype_xdigit($this->secret)) {
throw new InvalidSecretKeyException(sprintf('The secret key "%s" is not a hex key', $this->secret));
}
$this->secret = hex2bin($this->secret);
} | [
"public",
"function",
"turnHexKeyToBin",
"(",
")",
"{",
"if",
"(",
"!",
"ctype_xdigit",
"(",
"$",
"this",
"->",
"secret",
")",
")",
"{",
"throw",
"new",
"InvalidSecretKeyException",
"(",
"sprintf",
"(",
"'The secret key \"%s\" is not a hex key'",
",",
"$",
"this",
"->",
"secret",
")",
")",
";",
"}",
"$",
"this",
"->",
"secret",
"=",
"hex2bin",
"(",
"$",
"this",
"->",
"secret",
")",
";",
"}"
]
| Turns the secret hex key into a binary key.
@throws InvalidSecretKeyException When the secret key is not a hex key. | [
"Turns",
"the",
"secret",
"hex",
"key",
"into",
"a",
"binary",
"key",
"."
]
| 571b5311e7230f5a1241706edacbb2346624634d | https://github.com/nicolasmure/NmureEncryptor/blob/571b5311e7230f5a1241706edacbb2346624634d/src/Encryptor.php#L143-L150 |
16,382 | stubbles/stubbles-webapp-core | src/main/php/response/Cookie.php | Cookie.create | public static function create(string $name, string $value = null): self
{
return new self($name, $value);
} | php | public static function create(string $name, string $value = null): self
{
return new self($name, $value);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"null",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
]
| creates the cookie
@param string $name name of the cookie
@param string $value value of the cookie
@return \stubbles\webapp\response\Cookie | [
"creates",
"the",
"cookie"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Cookie.php#L86-L89 |
16,383 | ellipsephp/container | src/Container.php | Container.serviceFactoryMap | private function serviceFactoryMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($factories, ServiceProviderInterface $provider) use ($wrap) {
return array_merge($factories, array_map($wrap, $provider->getFactories()));
}, []);
} | php | private function serviceFactoryMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($factories, ServiceProviderInterface $provider) use ($wrap) {
return array_merge($factories, array_map($wrap, $provider->getFactories()));
}, []);
} | [
"private",
"function",
"serviceFactoryMap",
"(",
"array",
"$",
"providers",
")",
":",
"array",
"{",
"$",
"wrap",
"=",
"function",
"(",
"$",
"factory",
")",
"{",
"return",
"[",
"$",
"factory",
"]",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"providers",
",",
"function",
"(",
"$",
"factories",
",",
"ServiceProviderInterface",
"$",
"provider",
")",
"use",
"(",
"$",
"wrap",
")",
"{",
"return",
"array_merge",
"(",
"$",
"factories",
",",
"array_map",
"(",
"$",
"wrap",
",",
"$",
"provider",
"->",
"getFactories",
"(",
")",
")",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
]
| Return a service factory map from the given service providers.
@param array $providers
@return array | [
"Return",
"a",
"service",
"factory",
"map",
"from",
"the",
"given",
"service",
"providers",
"."
]
| ae0836b071fa1751f41b50fc33e3196fcbced6bf | https://github.com/ellipsephp/container/blob/ae0836b071fa1751f41b50fc33e3196fcbced6bf/src/Container.php#L89-L98 |
16,384 | ellipsephp/container | src/Container.php | Container.serviceExtensionMap | private function serviceExtensionMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($extensions, ServiceProviderInterface $provider) use ($wrap) {
return array_merge_recursive($extensions, array_map($wrap, $provider->getExtensions()));
}, []);
} | php | private function serviceExtensionMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($extensions, ServiceProviderInterface $provider) use ($wrap) {
return array_merge_recursive($extensions, array_map($wrap, $provider->getExtensions()));
}, []);
} | [
"private",
"function",
"serviceExtensionMap",
"(",
"array",
"$",
"providers",
")",
":",
"array",
"{",
"$",
"wrap",
"=",
"function",
"(",
"$",
"factory",
")",
"{",
"return",
"[",
"$",
"factory",
"]",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"providers",
",",
"function",
"(",
"$",
"extensions",
",",
"ServiceProviderInterface",
"$",
"provider",
")",
"use",
"(",
"$",
"wrap",
")",
"{",
"return",
"array_merge_recursive",
"(",
"$",
"extensions",
",",
"array_map",
"(",
"$",
"wrap",
",",
"$",
"provider",
"->",
"getExtensions",
"(",
")",
")",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
]
| Return a service extension map from the given service providers.
@param array $providers
@return array | [
"Return",
"a",
"service",
"extension",
"map",
"from",
"the",
"given",
"service",
"providers",
"."
]
| ae0836b071fa1751f41b50fc33e3196fcbced6bf | https://github.com/ellipsephp/container/blob/ae0836b071fa1751f41b50fc33e3196fcbced6bf/src/Container.php#L106-L115 |
16,385 | tjbp/laravel-verify-emails | src/Auth/VerifyEmails/CanVerifyEmail.php | CanVerifyEmail.unverify | public function unverify()
{
VerifyEmail::sendVerificationLink($this, function (Message $message) {
$message->subject($this->getVerifyEmailSubject());
});
$this->setVerified(false);
} | php | public function unverify()
{
VerifyEmail::sendVerificationLink($this, function (Message $message) {
$message->subject($this->getVerifyEmailSubject());
});
$this->setVerified(false);
} | [
"public",
"function",
"unverify",
"(",
")",
"{",
"VerifyEmail",
"::",
"sendVerificationLink",
"(",
"$",
"this",
",",
"function",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"subject",
"(",
"$",
"this",
"->",
"getVerifyEmailSubject",
"(",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"setVerified",
"(",
"false",
")",
";",
"}"
]
| Unverify the user's email address.
@return void | [
"Unverify",
"the",
"user",
"s",
"email",
"address",
"."
]
| 1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6 | https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Auth/VerifyEmails/CanVerifyEmail.php#L66-L73 |
16,386 | axelitus/php-base | src/Flag.php | Flag.isOn | public static function isOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a power of 2.");
}
return static::is($value & $flag);
} | php | public static function isOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a power of 2.");
}
return static::is($value & $flag);
} | [
"public",
"static",
"function",
"isOn",
"(",
"$",
"value",
",",
"$",
"flag",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type int.\"",
")",
";",
"}",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"flag",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$flag parameter must be of type int and a power of 2.\"",
")",
";",
"}",
"return",
"static",
"::",
"is",
"(",
"$",
"value",
"&",
"$",
"flag",
")",
";",
"}"
]
| Checks if a flag is set in a given value.
@param int $value The value to test the flag on.
@param int $flag The flag to be tested.
@return bool Returns true if the flag is set in the value, false otherwise.
@throws \InvalidArgumentException | [
"Checks",
"if",
"a",
"flag",
"is",
"set",
"in",
"a",
"given",
"value",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L55-L66 |
16,387 | axelitus/php-base | src/Flag.php | Flag.setOn | public static function setOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (is_array($flag)) {
$ret = $value;
foreach ($flag as $item) {
$ret = static::setOn($ret, $item);
}
return $ret;
} elseif (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a power of 2.");
}
return ($value | $flag);
} | php | public static function setOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (is_array($flag)) {
$ret = $value;
foreach ($flag as $item) {
$ret = static::setOn($ret, $item);
}
return $ret;
} elseif (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a power of 2.");
}
return ($value | $flag);
} | [
"public",
"static",
"function",
"setOn",
"(",
"$",
"value",
",",
"$",
"flag",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type int.\"",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"flag",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"value",
";",
"foreach",
"(",
"$",
"flag",
"as",
"$",
"item",
")",
"{",
"$",
"ret",
"=",
"static",
"::",
"setOn",
"(",
"$",
"ret",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}",
"elseif",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"flag",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$flag parameter must be of type int and a power of 2.\"",
")",
";",
"}",
"return",
"(",
"$",
"value",
"|",
"$",
"flag",
")",
";",
"}"
]
| Sets a flag into a value.
@param int $value The value to set the flag on.
@param int|array $flag The flag(s) to be set.
@return int Returns the value with the flag on.
@throws \InvalidArgumentException | [
"Sets",
"a",
"flag",
"into",
"a",
"value",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L95-L113 |
16,388 | axelitus/php-base | src/Flag.php | Flag.getValues | public static function getValues($count)
{
if (!Int::is($count) || $count < 1) {
throw new \InvalidArgumentException("The \$count parameter must be of type int and greater than zero.");
}
$ret = [];
$flag = 1;
for ($i = 0; $i < $count; $i++) {
$ret[] = $flag;
$flag <<= 1;
}
return $ret;
} | php | public static function getValues($count)
{
if (!Int::is($count) || $count < 1) {
throw new \InvalidArgumentException("The \$count parameter must be of type int and greater than zero.");
}
$ret = [];
$flag = 1;
for ($i = 0; $i < $count; $i++) {
$ret[] = $flag;
$flag <<= 1;
}
return $ret;
} | [
"public",
"static",
"function",
"getValues",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"count",
")",
"||",
"$",
"count",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$count parameter must be of type int and greater than zero.\"",
")",
";",
"}",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"flag",
"=",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"flag",
";",
"$",
"flag",
"<<=",
"1",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Gets an array with n consecutive flag values.
@param int $count The number of flag values to return.
@return array The array containing the n flag values.
@throws \InvalidArgumentException | [
"Gets",
"an",
"array",
"with",
"n",
"consecutive",
"flag",
"values",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L152-L166 |
16,389 | axelitus/php-base | src/Flag.php | Flag.buildMask | public static function buildMask($flag1, $_ = null)
{
if (!static::is($flag1)) {
throw new \InvalidArgumentException("The first parameter must be a flag.");
}
$mask = $flag1;
$args = array_slice(func_get_args(), 1);
foreach ($args as $flag) {
if (!static::is($flag)) {
throw new \InvalidArgumentException("All parameters must be flags.");
}
$mask = $mask | $flag;
}
return $mask;
} | php | public static function buildMask($flag1, $_ = null)
{
if (!static::is($flag1)) {
throw new \InvalidArgumentException("The first parameter must be a flag.");
}
$mask = $flag1;
$args = array_slice(func_get_args(), 1);
foreach ($args as $flag) {
if (!static::is($flag)) {
throw new \InvalidArgumentException("All parameters must be flags.");
}
$mask = $mask | $flag;
}
return $mask;
} | [
"public",
"static",
"function",
"buildMask",
"(",
"$",
"flag1",
",",
"$",
"_",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"flag1",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The first parameter must be a flag.\"",
")",
";",
"}",
"$",
"mask",
"=",
"$",
"flag1",
";",
"$",
"args",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"flag",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"flag",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"All parameters must be flags.\"",
")",
";",
"}",
"$",
"mask",
"=",
"$",
"mask",
"|",
"$",
"flag",
";",
"}",
"return",
"$",
"mask",
";",
"}"
]
| Builds a flag mask with the given flags.
@param int $flag1 The first flag.
@param int $_ More flags.
@return int The mask containing all the flags given.
@throws \InvalidArgumentException | [
"Builds",
"a",
"flag",
"mask",
"with",
"the",
"given",
"flags",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L214-L231 |
16,390 | axelitus/php-base | src/Flag.php | Flag.mask | public static function mask($value, $mask)
{
if (!Int::is($value) || !Int::is($mask)) {
throw new \InvalidArgumentException("Both parameters must be integers.");
}
return ($value & $mask);
} | php | public static function mask($value, $mask)
{
if (!Int::is($value) || !Int::is($mask)) {
throw new \InvalidArgumentException("Both parameters must be integers.");
}
return ($value & $mask);
} | [
"public",
"static",
"function",
"mask",
"(",
"$",
"value",
",",
"$",
"mask",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
"||",
"!",
"Int",
"::",
"is",
"(",
"$",
"mask",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Both parameters must be integers.\"",
")",
";",
"}",
"return",
"(",
"$",
"value",
"&",
"$",
"mask",
")",
";",
"}"
]
| Applies the mask to the given value and returns the masked result.
@param int $value The value to apply the mask to.
@param int $mask The mask to apply.
@return int The masked value result.
@throws \InvalidArgumentException | [
"Applies",
"the",
"mask",
"to",
"the",
"given",
"value",
"and",
"returns",
"the",
"masked",
"result",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L242-L249 |
16,391 | gbprod/elastica-provider-bundle | src/ElasticaProviderBundle/Provider/Registry.php | Registry.get | public function get($index = null, $type = null)
{
return array_filter(
$this->entries,
function($entry) use ($index, $type) {
return $entry->match($index, $type);
}
);
} | php | public function get($index = null, $type = null)
{
return array_filter(
$this->entries,
function($entry) use ($index, $type) {
return $entry->match($index, $type);
}
);
} | [
"public",
"function",
"get",
"(",
"$",
"index",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"entries",
",",
"function",
"(",
"$",
"entry",
")",
"use",
"(",
"$",
"index",
",",
"$",
"type",
")",
"{",
"return",
"$",
"entry",
"->",
"match",
"(",
"$",
"index",
",",
"$",
"type",
")",
";",
"}",
")",
";",
"}"
]
| Get entries for index and type
@param string|null $index
@param string|null $type
@return array<ProviderEntry> | [
"Get",
"entries",
"for",
"index",
"and",
"type"
]
| ee1e2ca78651d570b7400049bf81d8405fc744fc | https://github.com/gbprod/elastica-provider-bundle/blob/ee1e2ca78651d570b7400049bf81d8405fc744fc/src/ElasticaProviderBundle/Provider/Registry.php#L37-L45 |
16,392 | discophp/framework | core/classes/TemplateLoader.class.php | TemplateLoader.getFinalName | public function getFinalName($name){
try {
return parent::findTemplate($name);
} catch(\Twig_Error_Loader $e){
$exts = \App::config('TEMPLATE_EXTENSION');
if($exts){
if(!is_array($exts)){
$exts = Array($exts);
}//if
foreach($exts as $e){
try {
return parent::findTemplate($name . $e);
} catch(\Twig_Error_Loader $e){ }
}//foreach
}//if
}//catch
throw new \Twig_Error_Loader("Twig Error Loader Exception : Could name find template `{$name}`");
} | php | public function getFinalName($name){
try {
return parent::findTemplate($name);
} catch(\Twig_Error_Loader $e){
$exts = \App::config('TEMPLATE_EXTENSION');
if($exts){
if(!is_array($exts)){
$exts = Array($exts);
}//if
foreach($exts as $e){
try {
return parent::findTemplate($name . $e);
} catch(\Twig_Error_Loader $e){ }
}//foreach
}//if
}//catch
throw new \Twig_Error_Loader("Twig Error Loader Exception : Could name find template `{$name}`");
} | [
"public",
"function",
"getFinalName",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"findTemplate",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"\\",
"Twig_Error_Loader",
"$",
"e",
")",
"{",
"$",
"exts",
"=",
"\\",
"App",
"::",
"config",
"(",
"'TEMPLATE_EXTENSION'",
")",
";",
"if",
"(",
"$",
"exts",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"exts",
")",
")",
"{",
"$",
"exts",
"=",
"Array",
"(",
"$",
"exts",
")",
";",
"}",
"//if",
"foreach",
"(",
"$",
"exts",
"as",
"$",
"e",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"findTemplate",
"(",
"$",
"name",
".",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"\\",
"Twig_Error_Loader",
"$",
"e",
")",
"{",
"}",
"}",
"//foreach",
"}",
"//if",
"}",
"//catch",
"throw",
"new",
"\\",
"Twig_Error_Loader",
"(",
"\"Twig Error Loader Exception : Could name find template `{$name}`\"",
")",
";",
"}"
]
| Get the final name where a template lives, regardless of whether it was called with an extension or not.
@param string $name The template name.
@return string The final template name.
@throws \Twig_Error_Loader | [
"Get",
"the",
"final",
"name",
"where",
"a",
"template",
"lives",
"regardless",
"of",
"whether",
"it",
"was",
"called",
"with",
"an",
"extension",
"or",
"not",
"."
]
| 40ff3ea5225810534195494dc6c21083da4d1356 | https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/TemplateLoader.class.php#L20-L50 |
16,393 | shawnsandy/ui-pages | src/PageKitServiceProvider.php | PageKitServiceProvider.pageTheme | public function pageTheme()
{
view()->composer("*", function ($view) {
/* get the theme if set in config */
$theme = config("pagekit.theme", null);
/* if not theme is set in the config */
/* check the theme folder if exist or use the theme in package*/
if (!$theme):
if (view()->exists("theme.page.index")):
$theme = "theme.page.";
else :
$theme = "page::";
endif;
endif;
view()->share('pageTheme', $theme);
}
);
} | php | public function pageTheme()
{
view()->composer("*", function ($view) {
/* get the theme if set in config */
$theme = config("pagekit.theme", null);
/* if not theme is set in the config */
/* check the theme folder if exist or use the theme in package*/
if (!$theme):
if (view()->exists("theme.page.index")):
$theme = "theme.page.";
else :
$theme = "page::";
endif;
endif;
view()->share('pageTheme', $theme);
}
);
} | [
"public",
"function",
"pageTheme",
"(",
")",
"{",
"view",
"(",
")",
"->",
"composer",
"(",
"\"*\"",
",",
"function",
"(",
"$",
"view",
")",
"{",
"/* get the theme if set in config */",
"$",
"theme",
"=",
"config",
"(",
"\"pagekit.theme\"",
",",
"null",
")",
";",
"/* if not theme is set in the config */",
"/* check the theme folder if exist or use the theme in package*/",
"if",
"(",
"!",
"$",
"theme",
")",
":",
"if",
"(",
"view",
"(",
")",
"->",
"exists",
"(",
"\"theme.page.index\"",
")",
")",
":",
"$",
"theme",
"=",
"\"theme.page.\"",
";",
"else",
":",
"$",
"theme",
"=",
"\"page::\"",
";",
"endif",
";",
"endif",
";",
"view",
"(",
")",
"->",
"share",
"(",
"'pageTheme'",
",",
"$",
"theme",
")",
";",
"}",
")",
";",
"}"
]
| get the default theme | [
"get",
"the",
"default",
"theme"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/PageKitServiceProvider.php#L105-L130 |
16,394 | pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.setAuthor | public function setAuthor(Author $author)
{
$this->attachment['author_name'] = $author;
if ($author->hasIcon()) {
$this->attachment['author_icon'] = $author->getIcon();
}
if ($author->hasLink()) {
$this->attachment['author_link'] = $author->getLink();
}
return $this;
} | php | public function setAuthor(Author $author)
{
$this->attachment['author_name'] = $author;
if ($author->hasIcon()) {
$this->attachment['author_icon'] = $author->getIcon();
}
if ($author->hasLink()) {
$this->attachment['author_link'] = $author->getLink();
}
return $this;
} | [
"public",
"function",
"setAuthor",
"(",
"Author",
"$",
"author",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'author_name'",
"]",
"=",
"$",
"author",
";",
"if",
"(",
"$",
"author",
"->",
"hasIcon",
"(",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'author_icon'",
"]",
"=",
"$",
"author",
"->",
"getIcon",
"(",
")",
";",
"}",
"if",
"(",
"$",
"author",
"->",
"hasLink",
"(",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'author_link'",
"]",
"=",
"$",
"author",
"->",
"getLink",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| The author parameters will display a small section at the top of a message attachment.
@param Author $author
@return self | [
"The",
"author",
"parameters",
"will",
"display",
"a",
"small",
"section",
"at",
"the",
"top",
"of",
"a",
"message",
"attachment",
"."
]
| 6755060ddd6429620fd4c7decbb95f05463fc36b | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L90-L103 |
16,395 | pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.setTitle | public function setTitle(Title $title)
{
$this->attachment['title'] = $title;
if ($title->hasLink()) {
$this->attachment['title_link'] = $title->getLink();
}
return $this;
} | php | public function setTitle(Title $title)
{
$this->attachment['title'] = $title;
if ($title->hasLink()) {
$this->attachment['title_link'] = $title->getLink();
}
return $this;
} | [
"public",
"function",
"setTitle",
"(",
"Title",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"if",
"(",
"$",
"title",
"->",
"hasLink",
"(",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'title_link'",
"]",
"=",
"$",
"title",
"->",
"getLink",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| The title is displayed as larger, bold text near the top of a message attachment.
@param Title $title
@return self | [
"The",
"title",
"is",
"displayed",
"as",
"larger",
"bold",
"text",
"near",
"the",
"top",
"of",
"a",
"message",
"attachment",
"."
]
| 6755060ddd6429620fd4c7decbb95f05463fc36b | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L112-L121 |
16,396 | pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.addField | public function addField(Field $field)
{
if (!isset($this->attachment['fields'])) {
$this->attachment['fields'] = [];
}
$this->attachment['fields'][] = $field;
return $this;
} | php | public function addField(Field $field)
{
if (!isset($this->attachment['fields'])) {
$this->attachment['fields'] = [];
}
$this->attachment['fields'][] = $field;
return $this;
} | [
"public",
"function",
"addField",
"(",
"Field",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attachment",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'fields'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"attachment",
"[",
"'fields'",
"]",
"[",
"]",
"=",
"$",
"field",
";",
"return",
"$",
"this",
";",
"}"
]
| Will be displayed in a table inside the message attachment.
@param Field $field
@return self | [
"Will",
"be",
"displayed",
"in",
"a",
"table",
"inside",
"the",
"message",
"attachment",
"."
]
| 6755060ddd6429620fd4c7decbb95f05463fc36b | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L130-L139 |
16,397 | gregorybesson/PlaygroundCore | src/Service/Image.php | Image.save | public function save($path = null)
{
if (is_null($path)) {
$path = $this->file;
}
imagejpeg($this->image, $path);
return $this;
} | php | public function save($path = null)
{
if (is_null($path)) {
$path = $this->file;
}
imagejpeg($this->image, $path);
return $this;
} | [
"public",
"function",
"save",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"file",
";",
"}",
"imagejpeg",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| save as jpeg
@param string $path
@return \PlaygroundCore\Service\Image | [
"save",
"as",
"jpeg"
]
| f8dfa4c7660b54354933b3c28c0cf35304a649df | https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Image.php#L93-L100 |
16,398 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/InputType.php | InputType.setTypes | public function setTypes($attr, $type = null)
{
if (is_array($attr))
$this->inputType = array_merge($this->inputType, $attr);
else
$this->inputType[$attr] = $type;
return $this;
} | php | public function setTypes($attr, $type = null)
{
if (is_array($attr))
$this->inputType = array_merge($this->inputType, $attr);
else
$this->inputType[$attr] = $type;
return $this;
} | [
"public",
"function",
"setTypes",
"(",
"$",
"attr",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attr",
")",
")",
"$",
"this",
"->",
"inputType",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"inputType",
",",
"$",
"attr",
")",
";",
"else",
"$",
"this",
"->",
"inputType",
"[",
"$",
"attr",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the Input types.
@param string|array $attr
@param array $value
@return self | [
"Sets",
"the",
"Input",
"types",
"."
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InputType.php#L34-L42 |
16,399 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/InputType.php | InputType.setTypesGroup | public function setTypesGroup($types, $attr = null)
{
if (! is_array($types))
$types = [$types => $attr];
foreach ($types as $type => $attrList) {
if (! is_array($attrList))
$attrList = [$attrList];
foreach ($attrList as $attr)
$this->inputType[$attr] = $type;
}
return $this;
} | php | public function setTypesGroup($types, $attr = null)
{
if (! is_array($types))
$types = [$types => $attr];
foreach ($types as $type => $attrList) {
if (! is_array($attrList))
$attrList = [$attrList];
foreach ($attrList as $attr)
$this->inputType[$attr] = $type;
}
return $this;
} | [
"public",
"function",
"setTypesGroup",
"(",
"$",
"types",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"[",
"$",
"types",
"=>",
"$",
"attr",
"]",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
"=>",
"$",
"attrList",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"attrList",
")",
")",
"$",
"attrList",
"=",
"[",
"$",
"attrList",
"]",
";",
"foreach",
"(",
"$",
"attrList",
"as",
"$",
"attr",
")",
"$",
"this",
"->",
"inputType",
"[",
"$",
"attr",
"]",
"=",
"$",
"type",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set new or change input types
@param string|array $types
@param array $attr
@return self | [
"Set",
"new",
"or",
"change",
"input",
"types"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InputType.php#L52-L66 |
Subsets and Splits