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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,000
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.order
|
private function order()
{
if ($this->startDate > $this->endDate) {
$tmp = clone $this->startDate;
$this->startDate = clone $this->endDate;
$this->endDate = clone $tmp;
unset($tmp);
}
return $this;
}
|
php
|
private function order()
{
if ($this->startDate > $this->endDate) {
$tmp = clone $this->startDate;
$this->startDate = clone $this->endDate;
$this->endDate = clone $tmp;
unset($tmp);
}
return $this;
}
|
[
"private",
"function",
"order",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startDate",
">",
"$",
"this",
"->",
"endDate",
")",
"{",
"$",
"tmp",
"=",
"clone",
"$",
"this",
"->",
"startDate",
";",
"$",
"this",
"->",
"startDate",
"=",
"clone",
"$",
"this",
"->",
"endDate",
";",
"$",
"this",
"->",
"endDate",
"=",
"clone",
"$",
"tmp",
";",
"unset",
"(",
"$",
"tmp",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Swap start and end dates of the period if.
@return $this
|
[
"Swap",
"start",
"and",
"end",
"dates",
"of",
"the",
"period",
"if",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L26-L36
|
225,001
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.thisWeek
|
public static function thisWeek()
{
$start = CarbonDate::today();
$end = CarbonDate::tomorrow();
if ($start->dayOfWeek !== CarbonDate::MONDAY) {
$start->modify('last monday');
}
return new static($start, $end);
}
|
php
|
public static function thisWeek()
{
$start = CarbonDate::today();
$end = CarbonDate::tomorrow();
if ($start->dayOfWeek !== CarbonDate::MONDAY) {
$start->modify('last monday');
}
return new static($start, $end);
}
|
[
"public",
"static",
"function",
"thisWeek",
"(",
")",
"{",
"$",
"start",
"=",
"CarbonDate",
"::",
"today",
"(",
")",
";",
"$",
"end",
"=",
"CarbonDate",
"::",
"tomorrow",
"(",
")",
";",
"if",
"(",
"$",
"start",
"->",
"dayOfWeek",
"!==",
"CarbonDate",
"::",
"MONDAY",
")",
"{",
"$",
"start",
"->",
"modify",
"(",
"'last monday'",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"start",
",",
"$",
"end",
")",
";",
"}"
] |
Create a CarbonPeriod from closest monday to today.
@return static
|
[
"Create",
"a",
"CarbonPeriod",
"from",
"closest",
"monday",
"to",
"today",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L127-L136
|
225,002
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.each
|
public function each(\DateInterval $interval, \Closure $callback)
{
$period = new static($this->start(), $this->start()->add($interval));
do {
$callback(new static(
$period->start(),
$period->end() > $this->endDate ? $this->endDate : $period->end()
));
} while ($period->add($interval)->start() < $this->endDate);
return $this;
}
|
php
|
public function each(\DateInterval $interval, \Closure $callback)
{
$period = new static($this->start(), $this->start()->add($interval));
do {
$callback(new static(
$period->start(),
$period->end() > $this->endDate ? $this->endDate : $period->end()
));
} while ($period->add($interval)->start() < $this->endDate);
return $this;
}
|
[
"public",
"function",
"each",
"(",
"\\",
"DateInterval",
"$",
"interval",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"period",
"=",
"new",
"static",
"(",
"$",
"this",
"->",
"start",
"(",
")",
",",
"$",
"this",
"->",
"start",
"(",
")",
"->",
"add",
"(",
"$",
"interval",
")",
")",
";",
"do",
"{",
"$",
"callback",
"(",
"new",
"static",
"(",
"$",
"period",
"->",
"start",
"(",
")",
",",
"$",
"period",
"->",
"end",
"(",
")",
">",
"$",
"this",
"->",
"endDate",
"?",
"$",
"this",
"->",
"endDate",
":",
"$",
"period",
"->",
"end",
"(",
")",
")",
")",
";",
"}",
"while",
"(",
"$",
"period",
"->",
"add",
"(",
"$",
"interval",
")",
"->",
"start",
"(",
")",
"<",
"$",
"this",
"->",
"endDate",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the internal iterator with interval for the instance.
@param \DateInterval $interval
@param \Closure $callback
@return CarbonDate|$this
|
[
"Set",
"the",
"internal",
"iterator",
"with",
"interval",
"for",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L202-L214
|
225,003
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.eachWeeks
|
public function eachWeeks($weeks = 1, \Closure $callback, $onlyFullWeek = false)
{
if ($this->lengthInWeeks() > 0) {
return $this->each(
new \DateInterval("P{$weeks}W"),
function (CarbonPeriod $period) use ($weeks, $callback, $onlyFullWeek) {
if (!$onlyFullWeek || $period->lengthInWeeks() === $weeks) {
call_user_func_array($callback, func_get_args());
}
}
);
}
return $this;
}
|
php
|
public function eachWeeks($weeks = 1, \Closure $callback, $onlyFullWeek = false)
{
if ($this->lengthInWeeks() > 0) {
return $this->each(
new \DateInterval("P{$weeks}W"),
function (CarbonPeriod $period) use ($weeks, $callback, $onlyFullWeek) {
if (!$onlyFullWeek || $period->lengthInWeeks() === $weeks) {
call_user_func_array($callback, func_get_args());
}
}
);
}
return $this;
}
|
[
"public",
"function",
"eachWeeks",
"(",
"$",
"weeks",
"=",
"1",
",",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"onlyFullWeek",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lengthInWeeks",
"(",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"each",
"(",
"new",
"\\",
"DateInterval",
"(",
"\"P{$weeks}W\"",
")",
",",
"function",
"(",
"CarbonPeriod",
"$",
"period",
")",
"use",
"(",
"$",
"weeks",
",",
"$",
"callback",
",",
"$",
"onlyFullWeek",
")",
"{",
"if",
"(",
"!",
"$",
"onlyFullWeek",
"||",
"$",
"period",
"->",
"lengthInWeeks",
"(",
")",
"===",
"$",
"weeks",
")",
"{",
"call_user_func_array",
"(",
"$",
"callback",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the internal iterator with week interval for the instance.
@param int $weeks
@param callable $callback
@param bool $onlyFullWeek
@return CarbonDate|$this
|
[
"Set",
"the",
"internal",
"iterator",
"with",
"week",
"interval",
"for",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L236-L250
|
225,004
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.eachMonths
|
public function eachMonths($months = 1, \Closure $callback, $onlyFullMonth = false)
{
if ($this->lengthInMonths() > 0) {
return $this->each(
new \DateInterval("P{$months}M"),
function (CarbonPeriod $period) use ($months, $callback, $onlyFullMonth) {
if (!$onlyFullMonth || $period->lengthInMonths() === $months) {
call_user_func_array($callback, func_get_args());
}
}
);
}
return $this;
}
|
php
|
public function eachMonths($months = 1, \Closure $callback, $onlyFullMonth = false)
{
if ($this->lengthInMonths() > 0) {
return $this->each(
new \DateInterval("P{$months}M"),
function (CarbonPeriod $period) use ($months, $callback, $onlyFullMonth) {
if (!$onlyFullMonth || $period->lengthInMonths() === $months) {
call_user_func_array($callback, func_get_args());
}
}
);
}
return $this;
}
|
[
"public",
"function",
"eachMonths",
"(",
"$",
"months",
"=",
"1",
",",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"onlyFullMonth",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lengthInMonths",
"(",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"each",
"(",
"new",
"\\",
"DateInterval",
"(",
"\"P{$months}M\"",
")",
",",
"function",
"(",
"CarbonPeriod",
"$",
"period",
")",
"use",
"(",
"$",
"months",
",",
"$",
"callback",
",",
"$",
"onlyFullMonth",
")",
"{",
"if",
"(",
"!",
"$",
"onlyFullMonth",
"||",
"$",
"period",
"->",
"lengthInMonths",
"(",
")",
"===",
"$",
"months",
")",
"{",
"call_user_func_array",
"(",
"$",
"callback",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the internal iterator with month interval for the instance.
@param int $months
@param callable $callback
@param bool $onlyFullMonth
@return CarbonDate|$this
|
[
"Set",
"the",
"internal",
"iterator",
"with",
"month",
"interval",
"for",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L260-L274
|
225,005
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.eachDayOfWeek
|
public function eachDayOfWeek($dayOfWeek, \Closure $callback)
{
$start = $this->startDate->copy();
if ($start->dayOfWeek !== $dayOfWeek) {
$start->next($dayOfWeek);
}
if ($start < $this->endDate) {
$period = new static($start, $this->endDate);
$period->eachDays(CarbonDate::DAYS_PER_WEEK, function (CarbonPeriod $period) use ($callback) {
$callback(new static($period->start(), $period->start()->addDay()));
});
}
return $this;
}
|
php
|
public function eachDayOfWeek($dayOfWeek, \Closure $callback)
{
$start = $this->startDate->copy();
if ($start->dayOfWeek !== $dayOfWeek) {
$start->next($dayOfWeek);
}
if ($start < $this->endDate) {
$period = new static($start, $this->endDate);
$period->eachDays(CarbonDate::DAYS_PER_WEEK, function (CarbonPeriod $period) use ($callback) {
$callback(new static($period->start(), $period->start()->addDay()));
});
}
return $this;
}
|
[
"public",
"function",
"eachDayOfWeek",
"(",
"$",
"dayOfWeek",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"startDate",
"->",
"copy",
"(",
")",
";",
"if",
"(",
"$",
"start",
"->",
"dayOfWeek",
"!==",
"$",
"dayOfWeek",
")",
"{",
"$",
"start",
"->",
"next",
"(",
"$",
"dayOfWeek",
")",
";",
"}",
"if",
"(",
"$",
"start",
"<",
"$",
"this",
"->",
"endDate",
")",
"{",
"$",
"period",
"=",
"new",
"static",
"(",
"$",
"start",
",",
"$",
"this",
"->",
"endDate",
")",
";",
"$",
"period",
"->",
"eachDays",
"(",
"CarbonDate",
"::",
"DAYS_PER_WEEK",
",",
"function",
"(",
"CarbonPeriod",
"$",
"period",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"new",
"static",
"(",
"$",
"period",
"->",
"start",
"(",
")",
",",
"$",
"period",
"->",
"start",
"(",
")",
"->",
"addDay",
"(",
")",
")",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the internal iterator for day of week for the instance.
@param $dayOfWeek
@param callable $callback
@return $this
|
[
"Set",
"the",
"internal",
"iterator",
"for",
"day",
"of",
"week",
"for",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L283-L299
|
225,006
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.add
|
public function add(\DateInterval $interval)
{
$this->startDate->add($interval);
$this->endDate->add($interval);
return $this;
}
|
php
|
public function add(\DateInterval $interval)
{
$this->startDate->add($interval);
$this->endDate->add($interval);
return $this;
}
|
[
"public",
"function",
"add",
"(",
"\\",
"DateInterval",
"$",
"interval",
")",
"{",
"$",
"this",
"->",
"startDate",
"->",
"add",
"(",
"$",
"interval",
")",
";",
"$",
"this",
"->",
"endDate",
"->",
"add",
"(",
"$",
"interval",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add \DateInterval to the instance.
@param \DateInterval $interval
@return $this
|
[
"Add",
"\\",
"DateInterval",
"to",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L377-L383
|
225,007
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.sub
|
public function sub(\DateInterval $interval)
{
$this->startDate->sub($interval);
$this->endDate->sub($interval);
return $this;
}
|
php
|
public function sub(\DateInterval $interval)
{
$this->startDate->sub($interval);
$this->endDate->sub($interval);
return $this;
}
|
[
"public",
"function",
"sub",
"(",
"\\",
"DateInterval",
"$",
"interval",
")",
"{",
"$",
"this",
"->",
"startDate",
"->",
"sub",
"(",
"$",
"interval",
")",
";",
"$",
"this",
"->",
"endDate",
"->",
"sub",
"(",
"$",
"interval",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sub \DateInterval from the instance.
@param \DateInterval $interval
@return $this
|
[
"Sub",
"\\",
"DateInterval",
"from",
"the",
"instance",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L391-L397
|
225,008
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.contains
|
public function contains(CarbonDate $date, $equal = true)
{
return $date->between($this->startDate, $this->endDate, $equal);
}
|
php
|
public function contains(CarbonDate $date, $equal = true)
{
return $date->between($this->startDate, $this->endDate, $equal);
}
|
[
"public",
"function",
"contains",
"(",
"CarbonDate",
"$",
"date",
",",
"$",
"equal",
"=",
"true",
")",
"{",
"return",
"$",
"date",
"->",
"between",
"(",
"$",
"this",
"->",
"startDate",
",",
"$",
"this",
"->",
"endDate",
",",
"$",
"equal",
")",
";",
"}"
] |
Determines if the instances contains a date.
@see \Carbon\Carbon::between
@param CarbonDate $date
@param bool $equal Indicates if a > and < comparison should be used or <= or >=
@return bool
|
[
"Determines",
"if",
"the",
"instances",
"contains",
"a",
"date",
"."
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L473-L476
|
225,009
|
advmaker/carbon-period
|
src/CarbonPeriod.php
|
CarbonPeriod.iterateDates
|
public function iterateDates(\Closure $callback)
{
$interval = new \DateInterval('P1D');
$period = new \DatePeriod($this->start()->copy()->startOfDay(), $interval, $this->end()->copy()->startOfDay());
foreach ($period as $date) {
$callback($date);
}
return $this;
}
|
php
|
public function iterateDates(\Closure $callback)
{
$interval = new \DateInterval('P1D');
$period = new \DatePeriod($this->start()->copy()->startOfDay(), $interval, $this->end()->copy()->startOfDay());
foreach ($period as $date) {
$callback($date);
}
return $this;
}
|
[
"public",
"function",
"iterateDates",
"(",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"interval",
"=",
"new",
"\\",
"DateInterval",
"(",
"'P1D'",
")",
";",
"$",
"period",
"=",
"new",
"\\",
"DatePeriod",
"(",
"$",
"this",
"->",
"start",
"(",
")",
"->",
"copy",
"(",
")",
"->",
"startOfDay",
"(",
")",
",",
"$",
"interval",
",",
"$",
"this",
"->",
"end",
"(",
")",
"->",
"copy",
"(",
")",
"->",
"startOfDay",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"period",
"as",
"$",
"date",
")",
"{",
"$",
"callback",
"(",
"$",
"date",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Iterate period over each day
@param \Closure $callback
@return CarbonPeriod
|
[
"Iterate",
"period",
"over",
"each",
"day"
] |
4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d
|
https://github.com/advmaker/carbon-period/blob/4a2ae54dd9be2a4f5ba6bb279788a676a9910a0d/src/CarbonPeriod.php#L485-L496
|
225,010
|
moeen-basra/laravel-passport-mongodb
|
src/RouteRegistrar.php
|
RouteRegistrar.forAuthorization
|
public function forAuthorization()
{
$this->router->group(['middleware' => ['web', 'auth']], function ($router) {
$router->get('/authorize', [
'uses' => 'AuthorizationController@authorize',
]);
$router->post('/authorize', [
'uses' => 'ApproveAuthorizationController@approve',
]);
$router->delete('/authorize', [
'uses' => 'DenyAuthorizationController@deny',
]);
});
}
|
php
|
public function forAuthorization()
{
$this->router->group(['middleware' => ['web', 'auth']], function ($router) {
$router->get('/authorize', [
'uses' => 'AuthorizationController@authorize',
]);
$router->post('/authorize', [
'uses' => 'ApproveAuthorizationController@approve',
]);
$router->delete('/authorize', [
'uses' => 'DenyAuthorizationController@deny',
]);
});
}
|
[
"public",
"function",
"forAuthorization",
"(",
")",
"{",
"$",
"this",
"->",
"router",
"->",
"group",
"(",
"[",
"'middleware'",
"=>",
"[",
"'web'",
",",
"'auth'",
"]",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"get",
"(",
"'/authorize'",
",",
"[",
"'uses'",
"=>",
"'AuthorizationController@authorize'",
",",
"]",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'/authorize'",
",",
"[",
"'uses'",
"=>",
"'ApproveAuthorizationController@approve'",
",",
"]",
")",
";",
"$",
"router",
"->",
"delete",
"(",
"'/authorize'",
",",
"[",
"'uses'",
"=>",
"'DenyAuthorizationController@deny'",
",",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Register the routes needed for authorization.
@return void
|
[
"Register",
"the",
"routes",
"needed",
"for",
"authorization",
"."
] |
738261912672e39f9f4f4e5bf420b99dbe303ef8
|
https://github.com/moeen-basra/laravel-passport-mongodb/blob/738261912672e39f9f4f4e5bf420b99dbe303ef8/src/RouteRegistrar.php#L46-L61
|
225,011
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.create
|
public static function create(string $path, string $content = '', bool $overwrite = true): self
{
$path = normalize_path($path);
if (is_file($path) && $overwrite) {
self::unlink($path);
}
if (!is_file($path)) {
if (is_writeable(dirname($path))) {
if ($handle = fopen($path, 'w')) {
fwrite($handle, $content);
fclose($handle);
return new static($path);
}
throw new FileException('Creating file ('.$path.') failed');
}
throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
FileException::NOT_WRITEABLE);
}
throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
}
|
php
|
public static function create(string $path, string $content = '', bool $overwrite = true): self
{
$path = normalize_path($path);
if (is_file($path) && $overwrite) {
self::unlink($path);
}
if (!is_file($path)) {
if (is_writeable(dirname($path))) {
if ($handle = fopen($path, 'w')) {
fwrite($handle, $content);
fclose($handle);
return new static($path);
}
throw new FileException('Creating file ('.$path.') failed');
}
throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
FileException::NOT_WRITEABLE);
}
throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
}
|
[
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"content",
"=",
"''",
",",
"bool",
"$",
"overwrite",
"=",
"true",
")",
":",
"self",
"{",
"$",
"path",
"=",
"normalize_path",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
"&&",
"$",
"overwrite",
")",
"{",
"self",
"::",
"unlink",
"(",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"is_writeable",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"if",
"(",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"path",
",",
"'w'",
")",
")",
"{",
"fwrite",
"(",
"$",
"handle",
",",
"$",
"content",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"return",
"new",
"static",
"(",
"$",
"path",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Creating file ('",
".",
"$",
"path",
".",
"') failed'",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot create file, because the directory ('",
".",
"dirname",
"(",
"$",
"path",
")",
".",
"') is not accessible'",
",",
"FileException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot create file, because the file path ('",
".",
"$",
"path",
".",
"') already exist'",
",",
"FileException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Create new file.
@param string $path File path
@param string $content File content
@param bool $overwrite Set FALSE to prevent overwriting, when the a file with the new file path already exists
@return static
@throws FileException
|
[
"Create",
"new",
"file",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L84-L105
|
225,012
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.getName
|
public function getName(bool $withExtension = true): string
{
if ($withExtension) {
return pathinfo($this->path, PATHINFO_BASENAME);
}
return pathinfo($this->path, PATHINFO_FILENAME);
}
|
php
|
public function getName(bool $withExtension = true): string
{
if ($withExtension) {
return pathinfo($this->path, PATHINFO_BASENAME);
}
return pathinfo($this->path, PATHINFO_FILENAME);
}
|
[
"public",
"function",
"getName",
"(",
"bool",
"$",
"withExtension",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"withExtension",
")",
"{",
"return",
"pathinfo",
"(",
"$",
"this",
"->",
"path",
",",
"PATHINFO_BASENAME",
")",
";",
"}",
"return",
"pathinfo",
"(",
"$",
"this",
"->",
"path",
",",
"PATHINFO_FILENAME",
")",
";",
"}"
] |
Get file name.
@param bool $withExtension Set FALSE for file name without extension
@return string
|
[
"Get",
"file",
"name",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L114-L121
|
225,013
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.getFormattedSize
|
public function getFormattedSize(): string
{
$kiloBytes = $this->getSize() / 1024;
if ($kiloBytes < 1024) {
return round($kiloBytes, 2).' KB';
}
$megaBytes = $kiloBytes / 1024;
if ($megaBytes < 1024) {
return round($megaBytes, 1).' MB';
}
return round($megaBytes / 1024, 1).' GB';
}
|
php
|
public function getFormattedSize(): string
{
$kiloBytes = $this->getSize() / 1024;
if ($kiloBytes < 1024) {
return round($kiloBytes, 2).' KB';
}
$megaBytes = $kiloBytes / 1024;
if ($megaBytes < 1024) {
return round($megaBytes, 1).' MB';
}
return round($megaBytes / 1024, 1).' GB';
}
|
[
"public",
"function",
"getFormattedSize",
"(",
")",
":",
"string",
"{",
"$",
"kiloBytes",
"=",
"$",
"this",
"->",
"getSize",
"(",
")",
"/",
"1024",
";",
"if",
"(",
"$",
"kiloBytes",
"<",
"1024",
")",
"{",
"return",
"round",
"(",
"$",
"kiloBytes",
",",
"2",
")",
".",
"' KB'",
";",
"}",
"$",
"megaBytes",
"=",
"$",
"kiloBytes",
"/",
"1024",
";",
"if",
"(",
"$",
"megaBytes",
"<",
"1024",
")",
"{",
"return",
"round",
"(",
"$",
"megaBytes",
",",
"1",
")",
".",
"' MB'",
";",
"}",
"return",
"round",
"(",
"$",
"megaBytes",
"/",
"1024",
",",
"1",
")",
".",
"' GB'",
";",
"}"
] |
Get formatted size as KB, MB or GB.
@return string
|
[
"Get",
"formatted",
"size",
"as",
"KB",
"MB",
"or",
"GB",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L148-L160
|
225,014
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.delete
|
public function delete(): bool
{
if (is_file($this->path)) {
if (is_writable($this->path)) {
return unlink($this->path);
}
throw new FileException('Cannot delete file, because ('.$this->path.') is not writable', FileException::NOT_WRITEABLE);
}
return true;
}
|
php
|
public function delete(): bool
{
if (is_file($this->path)) {
if (is_writable($this->path)) {
return unlink($this->path);
}
throw new FileException('Cannot delete file, because ('.$this->path.') is not writable', FileException::NOT_WRITEABLE);
}
return true;
}
|
[
"public",
"function",
"delete",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"if",
"(",
"is_writable",
"(",
"$",
"this",
"->",
"path",
")",
")",
"{",
"return",
"unlink",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot delete file, because ('",
".",
"$",
"this",
"->",
"path",
".",
"') is not writable'",
",",
"FileException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Delete file.
@return bool
@throws FileException
|
[
"Delete",
"file",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L199-L209
|
225,015
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.rename
|
public function rename(string $newFileName, bool $withExtension = true, bool $overwrite = true): self
{
if (!$withExtension) {
$newFileName = $newFileName.'.'.$this->getExtension();
}
$newFilePath = normalize_path($this->getDirectory().DIRECTORY_SEPARATOR.basename($newFileName));
if ($newFilePath === $this->getPath() || (($overwrite || !is_file($newFilePath)) && $this->move($newFilePath))) {
return self::load($newFilePath);
}
throw new FileException('Cannot rename the file, because the new file name ('.$newFileName.') already exists',
FileException::ALREADY_EXIST);
}
|
php
|
public function rename(string $newFileName, bool $withExtension = true, bool $overwrite = true): self
{
if (!$withExtension) {
$newFileName = $newFileName.'.'.$this->getExtension();
}
$newFilePath = normalize_path($this->getDirectory().DIRECTORY_SEPARATOR.basename($newFileName));
if ($newFilePath === $this->getPath() || (($overwrite || !is_file($newFilePath)) && $this->move($newFilePath))) {
return self::load($newFilePath);
}
throw new FileException('Cannot rename the file, because the new file name ('.$newFileName.') already exists',
FileException::ALREADY_EXIST);
}
|
[
"public",
"function",
"rename",
"(",
"string",
"$",
"newFileName",
",",
"bool",
"$",
"withExtension",
"=",
"true",
",",
"bool",
"$",
"overwrite",
"=",
"true",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"withExtension",
")",
"{",
"$",
"newFileName",
"=",
"$",
"newFileName",
".",
"'.'",
".",
"$",
"this",
"->",
"getExtension",
"(",
")",
";",
"}",
"$",
"newFilePath",
"=",
"normalize_path",
"(",
"$",
"this",
"->",
"getDirectory",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"basename",
"(",
"$",
"newFileName",
")",
")",
";",
"if",
"(",
"$",
"newFilePath",
"===",
"$",
"this",
"->",
"getPath",
"(",
")",
"||",
"(",
"(",
"$",
"overwrite",
"||",
"!",
"is_file",
"(",
"$",
"newFilePath",
")",
")",
"&&",
"$",
"this",
"->",
"move",
"(",
"$",
"newFilePath",
")",
")",
")",
"{",
"return",
"self",
"::",
"load",
"(",
"$",
"newFilePath",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot rename the file, because the new file name ('",
".",
"$",
"newFileName",
".",
"') already exists'",
",",
"FileException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Rename file with new file name.
@param string $newFileName New file name
@param bool $withExtension Set FALSE to prevent renaming the the file extension too
@param bool $overwrite Set FALSE to prevent overwriting, when the a file with the new file name already exists
@return File
@throws FileException
|
[
"Rename",
"file",
"with",
"new",
"file",
"name",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L245-L257
|
225,016
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.moveToDirectory
|
public function moveToDirectory(string $newDirectoryPath, bool $overwrite = true): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writable($newDirectoryPath)) {
$newFilePath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
if ($overwrite || !is_file($newFilePath)) {
if ((is_file($newFilePath) && is_writeable($newFilePath)) || !is_file($newFilePath)) {
return $this->move($newFilePath, $overwrite);
}
throw new FileException('Cannot move the file, because the existing file ('.$newFilePath.') is not writable and cannot be overwritten',
FileException::NOT_WRITEABLE);
}
throw new FileException('Cannot move the file, because a file with the same name ('.$newFilePath.') already exists',
FileException::ALREADY_EXIST);
}
throw new FolderException('Cannot move the file, because the new directory path ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot move the file, because the new directory path ('.$newDirectoryPath.') does not exist',
FolderException::DONT_EXIST);
}
|
php
|
public function moveToDirectory(string $newDirectoryPath, bool $overwrite = true): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writable($newDirectoryPath)) {
$newFilePath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
if ($overwrite || !is_file($newFilePath)) {
if ((is_file($newFilePath) && is_writeable($newFilePath)) || !is_file($newFilePath)) {
return $this->move($newFilePath, $overwrite);
}
throw new FileException('Cannot move the file, because the existing file ('.$newFilePath.') is not writable and cannot be overwritten',
FileException::NOT_WRITEABLE);
}
throw new FileException('Cannot move the file, because a file with the same name ('.$newFilePath.') already exists',
FileException::ALREADY_EXIST);
}
throw new FolderException('Cannot move the file, because the new directory path ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot move the file, because the new directory path ('.$newDirectoryPath.') does not exist',
FolderException::DONT_EXIST);
}
|
[
"public",
"function",
"moveToDirectory",
"(",
"string",
"$",
"newDirectoryPath",
",",
"bool",
"$",
"overwrite",
"=",
"true",
")",
":",
"self",
"{",
"$",
"newDirectoryPath",
"=",
"normalize_path",
"(",
"$",
"newDirectoryPath",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"if",
"(",
"is_writable",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"$",
"newFilePath",
"=",
"$",
"newDirectoryPath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"overwrite",
"||",
"!",
"is_file",
"(",
"$",
"newFilePath",
")",
")",
"{",
"if",
"(",
"(",
"is_file",
"(",
"$",
"newFilePath",
")",
"&&",
"is_writeable",
"(",
"$",
"newFilePath",
")",
")",
"||",
"!",
"is_file",
"(",
"$",
"newFilePath",
")",
")",
"{",
"return",
"$",
"this",
"->",
"move",
"(",
"$",
"newFilePath",
",",
"$",
"overwrite",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot move the file, because the existing file ('",
".",
"$",
"newFilePath",
".",
"') is not writable and cannot be overwritten'",
",",
"FileException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot move the file, because a file with the same name ('",
".",
"$",
"newFilePath",
".",
"') already exists'",
",",
"FileException",
"::",
"ALREADY_EXIST",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move the file, because the new directory path ('",
".",
"$",
"newDirectoryPath",
".",
"') is not writable'",
",",
"FolderException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move the file, because the new directory path ('",
".",
"$",
"newDirectoryPath",
".",
"') does not exist'",
",",
"FolderException",
"::",
"DONT_EXIST",
")",
";",
"}"
] |
Move file to new directory path.
@param string $newDirectoryPath New directory path
@param bool $overwrite Set FALSE to prevent overwriting, when a file with same name in the new directory path already exists
@return static
@throws FileException
@throws FolderException
|
[
"Move",
"file",
"to",
"new",
"directory",
"path",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L270-L292
|
225,017
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/File.php
|
File.copy
|
public function copy(string $newFilePath, bool $overwrite = true): self
{
$newFilePath = normalize_path($newFilePath);
if ($overwrite || !is_file($newFilePath)) {
if (copy($this->path, $newFilePath)) {
return new self($newFilePath);
}
throw new FileException('Cannot copy file to the new file path ('.$newFilePath.') for unknown reasons');
}
throw new FileException('Cannot copy file, because the new file path ('.$newFilePath.') already exists', FileException::ALREADY_EXIST);
}
|
php
|
public function copy(string $newFilePath, bool $overwrite = true): self
{
$newFilePath = normalize_path($newFilePath);
if ($overwrite || !is_file($newFilePath)) {
if (copy($this->path, $newFilePath)) {
return new self($newFilePath);
}
throw new FileException('Cannot copy file to the new file path ('.$newFilePath.') for unknown reasons');
}
throw new FileException('Cannot copy file, because the new file path ('.$newFilePath.') already exists', FileException::ALREADY_EXIST);
}
|
[
"public",
"function",
"copy",
"(",
"string",
"$",
"newFilePath",
",",
"bool",
"$",
"overwrite",
"=",
"true",
")",
":",
"self",
"{",
"$",
"newFilePath",
"=",
"normalize_path",
"(",
"$",
"newFilePath",
")",
";",
"if",
"(",
"$",
"overwrite",
"||",
"!",
"is_file",
"(",
"$",
"newFilePath",
")",
")",
"{",
"if",
"(",
"copy",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"newFilePath",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"newFilePath",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot copy file to the new file path ('",
".",
"$",
"newFilePath",
".",
"') for unknown reasons'",
")",
";",
"}",
"throw",
"new",
"FileException",
"(",
"'Cannot copy file, because the new file path ('",
".",
"$",
"newFilePath",
".",
"') already exists'",
",",
"FileException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Copy file to new file path.
@param string $newFilePath New file path
@param bool $overwrite Set FALSE to prevent overwriting, when the a file with the new file path already exist
@return static
@throws FileException
|
[
"Copy",
"file",
"to",
"new",
"file",
"path",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/File.php#L304-L315
|
225,018
|
bytic/Common
|
src/Controllers/Traits/Models/HasModelLister.php
|
HasModelLister.doModelsListing
|
protected function doModelsListing()
{
$query = $this->newIndexQuery();
$filters = $this->getRequestFilters();
$query = $this->getModelManager()->filter($query, $filters);
$pageNumber = intval($this->getRequest()->query->get('page', 1));
$itemsPerPage = $this->getRecordPaginator()->getItemsPerPage();
$this->getRecordPaginator()->setPage($pageNumber);
$this->getRecordPaginator()->paginate($query);
$items = $this->indexFindItems($query);
$this->indexPrepareItems($items);
$this->getView()->set('filters', $filters);
$this->getView()->set('filters', $filters);
$this->getView()->set('filtersManager', $this->getModelManager()->getFilterManager());
$this->getView()->set('title', $this->getModelManager()->getLabel('title'));
$this->getView()->Paginator()->setPaginator($this->getRecordPaginator());
$this->getView()->Paginator()->setURL($this->getModelManager()->getURL($filters));
// if ($pageNumber * $itemsPerPage < $this->recordLimit) {
// } else {
// $this->getView()->set('recordLimit', true);
// }
}
|
php
|
protected function doModelsListing()
{
$query = $this->newIndexQuery();
$filters = $this->getRequestFilters();
$query = $this->getModelManager()->filter($query, $filters);
$pageNumber = intval($this->getRequest()->query->get('page', 1));
$itemsPerPage = $this->getRecordPaginator()->getItemsPerPage();
$this->getRecordPaginator()->setPage($pageNumber);
$this->getRecordPaginator()->paginate($query);
$items = $this->indexFindItems($query);
$this->indexPrepareItems($items);
$this->getView()->set('filters', $filters);
$this->getView()->set('filters', $filters);
$this->getView()->set('filtersManager', $this->getModelManager()->getFilterManager());
$this->getView()->set('title', $this->getModelManager()->getLabel('title'));
$this->getView()->Paginator()->setPaginator($this->getRecordPaginator());
$this->getView()->Paginator()->setURL($this->getModelManager()->getURL($filters));
// if ($pageNumber * $itemsPerPage < $this->recordLimit) {
// } else {
// $this->getView()->set('recordLimit', true);
// }
}
|
[
"protected",
"function",
"doModelsListing",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newIndexQuery",
"(",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"getRequestFilters",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"filter",
"(",
"$",
"query",
",",
"$",
"filters",
")",
";",
"$",
"pageNumber",
"=",
"intval",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"query",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
")",
";",
"$",
"itemsPerPage",
"=",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
"->",
"getItemsPerPage",
"(",
")",
";",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
"->",
"setPage",
"(",
"$",
"pageNumber",
")",
";",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
"->",
"paginate",
"(",
"$",
"query",
")",
";",
"$",
"items",
"=",
"$",
"this",
"->",
"indexFindItems",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"indexPrepareItems",
"(",
"$",
"items",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'filters'",
",",
"$",
"filters",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'filters'",
",",
"$",
"filters",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'filtersManager'",
",",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getFilterManager",
"(",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'title'",
",",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getLabel",
"(",
"'title'",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"Paginator",
"(",
")",
"->",
"setPaginator",
"(",
"$",
"this",
"->",
"getRecordPaginator",
"(",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"Paginator",
"(",
")",
"->",
"setURL",
"(",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getURL",
"(",
"$",
"filters",
")",
")",
";",
"// if ($pageNumber * $itemsPerPage < $this->recordLimit) {",
"// } else {",
"// $this->getView()->set('recordLimit', true);",
"// }",
"}"
] |
Does the model listing
@return void
|
[
"Does",
"the",
"model",
"listing"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/Models/HasModelLister.php#L24-L51
|
225,019
|
Erebot/API
|
src/Autoload.php
|
Autoload.initialize
|
public static function initialize($path = null, $mapfile = null)
{
self::register();
self::addPath($path);
self::addMap($mapfile);
}
|
php
|
public static function initialize($path = null, $mapfile = null)
{
self::register();
self::addPath($path);
self::addMap($mapfile);
}
|
[
"public",
"static",
"function",
"initialize",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"mapfile",
"=",
"null",
")",
"{",
"self",
"::",
"register",
"(",
")",
";",
"self",
"::",
"addPath",
"(",
"$",
"path",
")",
";",
"self",
"::",
"addMap",
"(",
"$",
"mapfile",
")",
";",
"}"
] |
Initialize the PEAR2 autoloader
\param string $path
Directory path to register
\param string $mapfile
Path to a classname-to-file map file.
\return
This method does not return anything.
|
[
"Initialize",
"the",
"PEAR2",
"autoloader"
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L47-L52
|
225,020
|
Erebot/API
|
src/Autoload.php
|
Autoload.register
|
protected static function register()
{
if (!self::$registered) {
// set up __autoload
$autoload = spl_autoload_functions();
spl_autoload_register(__CLASS__.'::load');
if (function_exists('__autoload') && ($autoload === false)) {
// __autoload() was being used, but now would be ignored, add
// it to the autoload stack
spl_autoload_register('__autoload');
}
}
self::$registered = true;
}
|
php
|
protected static function register()
{
if (!self::$registered) {
// set up __autoload
$autoload = spl_autoload_functions();
spl_autoload_register(__CLASS__.'::load');
if (function_exists('__autoload') && ($autoload === false)) {
// __autoload() was being used, but now would be ignored, add
// it to the autoload stack
spl_autoload_register('__autoload');
}
}
self::$registered = true;
}
|
[
"protected",
"static",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"registered",
")",
"{",
"// set up __autoload",
"$",
"autoload",
"=",
"spl_autoload_functions",
"(",
")",
";",
"spl_autoload_register",
"(",
"__CLASS__",
".",
"'::load'",
")",
";",
"if",
"(",
"function_exists",
"(",
"'__autoload'",
")",
"&&",
"(",
"$",
"autoload",
"===",
"false",
")",
")",
"{",
"// __autoload() was being used, but now would be ignored, add",
"// it to the autoload stack",
"spl_autoload_register",
"(",
"'__autoload'",
")",
";",
"}",
"}",
"self",
"::",
"$",
"registered",
"=",
"true",
";",
"}"
] |
Register the PEAR2 autoload class with spl_autoload_register
\return
This method does not return anything.
|
[
"Register",
"the",
"PEAR2",
"autoload",
"class",
"with",
"spl_autoload_register"
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L60-L73
|
225,021
|
Erebot/API
|
src/Autoload.php
|
Autoload.addMap
|
protected static function addMap($mapfile)
{
if (! in_array($mapfile, self::$maps)) {
// keep track of specific map file loaded in this
// instance so we can update it if necessary
self::$mapfile = $mapfile;
if (file_exists($mapfile)) {
$map = include $mapfile;
if (is_array($map)) {
// mapfile contains a valid map, so we'll keep it
self::$maps[] = $mapfile;
self::$map = array_merge(self::$map, $map);
}
}
}
}
|
php
|
protected static function addMap($mapfile)
{
if (! in_array($mapfile, self::$maps)) {
// keep track of specific map file loaded in this
// instance so we can update it if necessary
self::$mapfile = $mapfile;
if (file_exists($mapfile)) {
$map = include $mapfile;
if (is_array($map)) {
// mapfile contains a valid map, so we'll keep it
self::$maps[] = $mapfile;
self::$map = array_merge(self::$map, $map);
}
}
}
}
|
[
"protected",
"static",
"function",
"addMap",
"(",
"$",
"mapfile",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"mapfile",
",",
"self",
"::",
"$",
"maps",
")",
")",
"{",
"// keep track of specific map file loaded in this",
"// instance so we can update it if necessary",
"self",
"::",
"$",
"mapfile",
"=",
"$",
"mapfile",
";",
"if",
"(",
"file_exists",
"(",
"$",
"mapfile",
")",
")",
"{",
"$",
"map",
"=",
"include",
"$",
"mapfile",
";",
"if",
"(",
"is_array",
"(",
"$",
"map",
")",
")",
"{",
"// mapfile contains a valid map, so we'll keep it",
"self",
"::",
"$",
"maps",
"[",
"]",
"=",
"$",
"mapfile",
";",
"self",
"::",
"$",
"map",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"map",
",",
"$",
"map",
")",
";",
"}",
"}",
"}",
"}"
] |
Add a classname-to-file map
\param string $mapfile
The filename of the classmap
\return
This method does not return anything.
|
[
"Add",
"a",
"classname",
"-",
"to",
"-",
"file",
"map"
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L113-L129
|
225,022
|
Erebot/API
|
src/Autoload.php
|
Autoload.isMapped
|
protected static function isMapped($class)
{
if (isset(self::$map[$class])) {
return true;
}
if (isset(self::$mapfile) && ! isset(self::$map[$class])) {
self::$unmapped[] = $class;
return false;
}
return false;
}
|
php
|
protected static function isMapped($class)
{
if (isset(self::$map[$class])) {
return true;
}
if (isset(self::$mapfile) && ! isset(self::$map[$class])) {
self::$unmapped[] = $class;
return false;
}
return false;
}
|
[
"protected",
"static",
"function",
"isMapped",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"map",
"[",
"$",
"class",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"mapfile",
")",
"&&",
"!",
"isset",
"(",
"self",
"::",
"$",
"map",
"[",
"$",
"class",
"]",
")",
")",
"{",
"self",
"::",
"$",
"unmapped",
"[",
"]",
"=",
"$",
"class",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the class is already defined in a classmap
\param string $class
The class to look for
\retval bool
TRUE if the class is already defined,
FALSE otherwise.
|
[
"Check",
"if",
"the",
"class",
"is",
"already",
"defined",
"in",
"a",
"classmap"
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L141-L151
|
225,023
|
Erebot/API
|
src/Autoload.php
|
Autoload.load
|
public static function load($class)
{
/* Protects us from possible remote code inclusion due to:
https://bugs.php.net/bug.php?id=55475
We should already be safe without this check due to the
way this autoloader works, but this helps other autoloaders
that use other mechanisms and may be vulnerable. */
if (strpos($class, ":") !== false) {
// Safer than returning false as it prevents
// other autoloaders from ever executing...
throw new \Exception('Possible remote code injection detected');
}
// need to check if there's a current map file specified ALSO.
// this could be the first time writing it.
$mapped = self::isMapped($class);
if ($mapped) {
require_once self::$map[$class];
if (!self::loadSuccessful($class)) {
// record this failure & keep going, we may still find it
self::$unmapped[] = $class;
} else {
return true;
}
}
$file = str_replace(
array('_', '\\'),
DIRECTORY_SEPARATOR,
$class
) . '.php';
foreach (self::$paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
require_once $path . DIRECTORY_SEPARATOR . $file;
if (!self::loadSuccessful($class)) {
throw new \Exception(
'Class ' . $class . ' was not present in ' .
$path . DIRECTORY_SEPARATOR . $file .
'") [Autoload]'
);
}
if (in_array($class, self::$unmapped)) {
self::updateMap(
$class,
$path . DIRECTORY_SEPARATOR . $file
);
}
return true;
}
}
$e = new \Exception(
'Class ' . $class . ' could not be loaded from ' .
$file . ', file does not exist (registered paths="' .
implode(PATH_SEPARATOR, self::$paths) .
'") [Autoload]'
);
$trace = $e->getTrace();
if (isset($trace[2]) && isset($trace[2]['function']) &&
in_array(
$trace[2]['function'],
array('class_exists', 'interface_exists')
)) {
return false;
}
if (isset($trace[1]) && isset($trace[1]['function']) &&
in_array(
$trace[1]['function'],
array('class_exists', 'interface_exists')
)) {
return false;
}
// If there are other autoload functions registered,
// let's try to play nicely with them...
// ...otherwise, we just throw an exception.
if (count(spl_autoload_functions()) == 1) {
throw $e;
}
return false;
}
|
php
|
public static function load($class)
{
/* Protects us from possible remote code inclusion due to:
https://bugs.php.net/bug.php?id=55475
We should already be safe without this check due to the
way this autoloader works, but this helps other autoloaders
that use other mechanisms and may be vulnerable. */
if (strpos($class, ":") !== false) {
// Safer than returning false as it prevents
// other autoloaders from ever executing...
throw new \Exception('Possible remote code injection detected');
}
// need to check if there's a current map file specified ALSO.
// this could be the first time writing it.
$mapped = self::isMapped($class);
if ($mapped) {
require_once self::$map[$class];
if (!self::loadSuccessful($class)) {
// record this failure & keep going, we may still find it
self::$unmapped[] = $class;
} else {
return true;
}
}
$file = str_replace(
array('_', '\\'),
DIRECTORY_SEPARATOR,
$class
) . '.php';
foreach (self::$paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
require_once $path . DIRECTORY_SEPARATOR . $file;
if (!self::loadSuccessful($class)) {
throw new \Exception(
'Class ' . $class . ' was not present in ' .
$path . DIRECTORY_SEPARATOR . $file .
'") [Autoload]'
);
}
if (in_array($class, self::$unmapped)) {
self::updateMap(
$class,
$path . DIRECTORY_SEPARATOR . $file
);
}
return true;
}
}
$e = new \Exception(
'Class ' . $class . ' could not be loaded from ' .
$file . ', file does not exist (registered paths="' .
implode(PATH_SEPARATOR, self::$paths) .
'") [Autoload]'
);
$trace = $e->getTrace();
if (isset($trace[2]) && isset($trace[2]['function']) &&
in_array(
$trace[2]['function'],
array('class_exists', 'interface_exists')
)) {
return false;
}
if (isset($trace[1]) && isset($trace[1]['function']) &&
in_array(
$trace[1]['function'],
array('class_exists', 'interface_exists')
)) {
return false;
}
// If there are other autoload functions registered,
// let's try to play nicely with them...
// ...otherwise, we just throw an exception.
if (count(spl_autoload_functions()) == 1) {
throw $e;
}
return false;
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"/* Protects us from possible remote code inclusion due to:\n https://bugs.php.net/bug.php?id=55475\n We should already be safe without this check due to the\n way this autoloader works, but this helps other autoloaders\n that use other mechanisms and may be vulnerable. */",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"\":\"",
")",
"!==",
"false",
")",
"{",
"// Safer than returning false as it prevents",
"// other autoloaders from ever executing...",
"throw",
"new",
"\\",
"Exception",
"(",
"'Possible remote code injection detected'",
")",
";",
"}",
"// need to check if there's a current map file specified ALSO.",
"// this could be the first time writing it.",
"$",
"mapped",
"=",
"self",
"::",
"isMapped",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"mapped",
")",
"{",
"require_once",
"self",
"::",
"$",
"map",
"[",
"$",
"class",
"]",
";",
"if",
"(",
"!",
"self",
"::",
"loadSuccessful",
"(",
"$",
"class",
")",
")",
"{",
"// record this failure & keep going, we may still find it",
"self",
"::",
"$",
"unmapped",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"$",
"file",
"=",
"str_replace",
"(",
"array",
"(",
"'_'",
",",
"'\\\\'",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"class",
")",
".",
"'.php'",
";",
"foreach",
"(",
"self",
"::",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
")",
"{",
"require_once",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
";",
"if",
"(",
"!",
"self",
"::",
"loadSuccessful",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Class '",
".",
"$",
"class",
".",
"' was not present in '",
".",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
".",
"'\") [Autoload]'",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"unmapped",
")",
")",
"{",
"self",
"::",
"updateMap",
"(",
"$",
"class",
",",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
")",
";",
"}",
"return",
"true",
";",
"}",
"}",
"$",
"e",
"=",
"new",
"\\",
"Exception",
"(",
"'Class '",
".",
"$",
"class",
".",
"' could not be loaded from '",
".",
"$",
"file",
".",
"', file does not exist (registered paths=\"'",
".",
"implode",
"(",
"PATH_SEPARATOR",
",",
"self",
"::",
"$",
"paths",
")",
".",
"'\") [Autoload]'",
")",
";",
"$",
"trace",
"=",
"$",
"e",
"->",
"getTrace",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"2",
"]",
")",
"&&",
"isset",
"(",
"$",
"trace",
"[",
"2",
"]",
"[",
"'function'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"trace",
"[",
"2",
"]",
"[",
"'function'",
"]",
",",
"array",
"(",
"'class_exists'",
",",
"'interface_exists'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"trace",
"[",
"1",
"]",
")",
"&&",
"isset",
"(",
"$",
"trace",
"[",
"1",
"]",
"[",
"'function'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"trace",
"[",
"1",
"]",
"[",
"'function'",
"]",
",",
"array",
"(",
"'class_exists'",
",",
"'interface_exists'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If there are other autoload functions registered,",
"// let's try to play nicely with them...",
"// ...otherwise, we just throw an exception.",
"if",
"(",
"count",
"(",
"spl_autoload_functions",
"(",
")",
")",
"==",
"1",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"false",
";",
"}"
] |
Load a PEAR2 class
\param string $class
The class to load
\retval bool
TRUE if the class could be loaded,
FALSE otherwise.
|
[
"Load",
"a",
"PEAR2",
"class"
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L163-L244
|
225,024
|
Erebot/API
|
src/Autoload.php
|
Autoload.updateMap
|
protected static function updateMap($class, $origin)
{
if (is_writable(self::$mapfile) ||
is_writable(dirname(self::$mapfile))) {
self::$map[$class] = $origin;
file_put_contents(
self::$mapfile,
'<'."?php\n"
. "// Autoload auto-generated classmap\n"
. "return " . var_export(self::$map, true) . ';',
LOCK_EX
);
}
}
|
php
|
protected static function updateMap($class, $origin)
{
if (is_writable(self::$mapfile) ||
is_writable(dirname(self::$mapfile))) {
self::$map[$class] = $origin;
file_put_contents(
self::$mapfile,
'<'."?php\n"
. "// Autoload auto-generated classmap\n"
. "return " . var_export(self::$map, true) . ';',
LOCK_EX
);
}
}
|
[
"protected",
"static",
"function",
"updateMap",
"(",
"$",
"class",
",",
"$",
"origin",
")",
"{",
"if",
"(",
"is_writable",
"(",
"self",
"::",
"$",
"mapfile",
")",
"||",
"is_writable",
"(",
"dirname",
"(",
"self",
"::",
"$",
"mapfile",
")",
")",
")",
"{",
"self",
"::",
"$",
"map",
"[",
"$",
"class",
"]",
"=",
"$",
"origin",
";",
"file_put_contents",
"(",
"self",
"::",
"$",
"mapfile",
",",
"'<'",
".",
"\"?php\\n\"",
".",
"\"// Autoload auto-generated classmap\\n\"",
".",
"\"return \"",
".",
"var_export",
"(",
"self",
"::",
"$",
"map",
",",
"true",
")",
".",
"';'",
",",
"LOCK_EX",
")",
";",
"}",
"}"
] |
If possible, update the classmap file with newly-discovered
mapping.
\param string $class
Class name discovered
\param string $origin
File where class was found
\return
This method does not return anything.
|
[
"If",
"possible",
"update",
"the",
"classmap",
"file",
"with",
"newly",
"-",
"discovered",
"mapping",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Autoload.php#L278-L291
|
225,025
|
byjg/convert
|
src/ToUTF8.php
|
ToUTF8.baseConversion
|
protected static function baseConversion($vector, $text)
{
foreach ($vector as $key => $value) {
$char = $value;
if (is_array($value)) {
$char = "";
foreach ($value as $ascii) {
$char .= chr($ascii);
}
}
$text = str_replace($key, $char, $text);
}
return $text;
}
|
php
|
protected static function baseConversion($vector, $text)
{
foreach ($vector as $key => $value) {
$char = $value;
if (is_array($value)) {
$char = "";
foreach ($value as $ascii) {
$char .= chr($ascii);
}
}
$text = str_replace($key, $char, $text);
}
return $text;
}
|
[
"protected",
"static",
"function",
"baseConversion",
"(",
"$",
"vector",
",",
"$",
"text",
")",
"{",
"foreach",
"(",
"$",
"vector",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"char",
"=",
"$",
"value",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"char",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"ascii",
")",
"{",
"$",
"char",
".=",
"chr",
"(",
"$",
"ascii",
")",
";",
"}",
"}",
"$",
"text",
"=",
"str_replace",
"(",
"$",
"key",
",",
"$",
"char",
",",
"$",
"text",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Base convert based on array
@param string[] $vector
@param string $text
@return string
|
[
"Base",
"convert",
"based",
"on",
"array"
] |
a1b360b80b624037b35fa512164bf33e38860ee8
|
https://github.com/byjg/convert/blob/a1b360b80b624037b35fa512164bf33e38860ee8/src/ToUTF8.php#L485-L499
|
225,026
|
RevisionTen/cqrs
|
Services/AggregateFactory.php
|
AggregateFactory.build
|
public function build(string $uuid, string $aggregateClass, int $max_version = null, int $user = null): AggregateInterface
{
try {
/**
* @var AggregateInterface $aggregate
*/
$aggregate = new $aggregateClass($uuid);
if ($aggregate instanceof AggregateInterface) {
/**
* Get latest matching Snapshot.
*
* @var Snapshot $snapshot
*/
$snapshot = $this->snapshotStore->find($uuid, $max_version);
$min_version = $snapshot ? ($snapshot->getVersion() + 1) : null;
if ($snapshot) {
$aggregate = $this->loadFromSnapshot($aggregate, $snapshot);
}
/**
* Get Event Stream Objects.
*
* @var EventStreamObject[] $eventStreamObjects
*/
$eventStreamObjects = $this->eventStore->find($uuid, $max_version, $min_version);
if ($eventStreamObjects) {
$aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
}
// Set the current version that is recorded in the event stream.
$aggregate->setStreamVersion($aggregate->getVersion());
if (null !== $user) {
/**
* Get qeued Event Stream Objects.
*
* @var EventStreamObject[] $eventStreamObjects
*/
$eventStreamObjects = $this->eventStore->findQeued($uuid, $max_version, $aggregate->getVersion() + 1, $user);
if ($eventStreamObjects) {
$aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
}
}
} else {
// Instantiate generic Aggregate to prevent Handler from failing.
$aggregate = new Aggregate($uuid);
throw new AggregateException($aggregateClass.' must implement '.AggregateInterface::class);
}
} catch (AggregateException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
$uuid,
$e
));
}
return $aggregate;
}
|
php
|
public function build(string $uuid, string $aggregateClass, int $max_version = null, int $user = null): AggregateInterface
{
try {
/**
* @var AggregateInterface $aggregate
*/
$aggregate = new $aggregateClass($uuid);
if ($aggregate instanceof AggregateInterface) {
/**
* Get latest matching Snapshot.
*
* @var Snapshot $snapshot
*/
$snapshot = $this->snapshotStore->find($uuid, $max_version);
$min_version = $snapshot ? ($snapshot->getVersion() + 1) : null;
if ($snapshot) {
$aggregate = $this->loadFromSnapshot($aggregate, $snapshot);
}
/**
* Get Event Stream Objects.
*
* @var EventStreamObject[] $eventStreamObjects
*/
$eventStreamObjects = $this->eventStore->find($uuid, $max_version, $min_version);
if ($eventStreamObjects) {
$aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
}
// Set the current version that is recorded in the event stream.
$aggregate->setStreamVersion($aggregate->getVersion());
if (null !== $user) {
/**
* Get qeued Event Stream Objects.
*
* @var EventStreamObject[] $eventStreamObjects
*/
$eventStreamObjects = $this->eventStore->findQeued($uuid, $max_version, $aggregate->getVersion() + 1, $user);
if ($eventStreamObjects) {
$aggregate = $this->loadFromHistory($aggregate, $eventStreamObjects);
}
}
} else {
// Instantiate generic Aggregate to prevent Handler from failing.
$aggregate = new Aggregate($uuid);
throw new AggregateException($aggregateClass.' must implement '.AggregateInterface::class);
}
} catch (AggregateException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
$uuid,
$e
));
}
return $aggregate;
}
|
[
"public",
"function",
"build",
"(",
"string",
"$",
"uuid",
",",
"string",
"$",
"aggregateClass",
",",
"int",
"$",
"max_version",
"=",
"null",
",",
"int",
"$",
"user",
"=",
"null",
")",
":",
"AggregateInterface",
"{",
"try",
"{",
"/**\n * @var AggregateInterface $aggregate\n */",
"$",
"aggregate",
"=",
"new",
"$",
"aggregateClass",
"(",
"$",
"uuid",
")",
";",
"if",
"(",
"$",
"aggregate",
"instanceof",
"AggregateInterface",
")",
"{",
"/**\n * Get latest matching Snapshot.\n *\n * @var Snapshot $snapshot\n */",
"$",
"snapshot",
"=",
"$",
"this",
"->",
"snapshotStore",
"->",
"find",
"(",
"$",
"uuid",
",",
"$",
"max_version",
")",
";",
"$",
"min_version",
"=",
"$",
"snapshot",
"?",
"(",
"$",
"snapshot",
"->",
"getVersion",
"(",
")",
"+",
"1",
")",
":",
"null",
";",
"if",
"(",
"$",
"snapshot",
")",
"{",
"$",
"aggregate",
"=",
"$",
"this",
"->",
"loadFromSnapshot",
"(",
"$",
"aggregate",
",",
"$",
"snapshot",
")",
";",
"}",
"/**\n * Get Event Stream Objects.\n *\n * @var EventStreamObject[] $eventStreamObjects\n */",
"$",
"eventStreamObjects",
"=",
"$",
"this",
"->",
"eventStore",
"->",
"find",
"(",
"$",
"uuid",
",",
"$",
"max_version",
",",
"$",
"min_version",
")",
";",
"if",
"(",
"$",
"eventStreamObjects",
")",
"{",
"$",
"aggregate",
"=",
"$",
"this",
"->",
"loadFromHistory",
"(",
"$",
"aggregate",
",",
"$",
"eventStreamObjects",
")",
";",
"}",
"// Set the current version that is recorded in the event stream.",
"$",
"aggregate",
"->",
"setStreamVersion",
"(",
"$",
"aggregate",
"->",
"getVersion",
"(",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"user",
")",
"{",
"/**\n * Get qeued Event Stream Objects.\n *\n * @var EventStreamObject[] $eventStreamObjects\n */",
"$",
"eventStreamObjects",
"=",
"$",
"this",
"->",
"eventStore",
"->",
"findQeued",
"(",
"$",
"uuid",
",",
"$",
"max_version",
",",
"$",
"aggregate",
"->",
"getVersion",
"(",
")",
"+",
"1",
",",
"$",
"user",
")",
";",
"if",
"(",
"$",
"eventStreamObjects",
")",
"{",
"$",
"aggregate",
"=",
"$",
"this",
"->",
"loadFromHistory",
"(",
"$",
"aggregate",
",",
"$",
"eventStreamObjects",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// Instantiate generic Aggregate to prevent Handler from failing.",
"$",
"aggregate",
"=",
"new",
"Aggregate",
"(",
"$",
"uuid",
")",
";",
"throw",
"new",
"AggregateException",
"(",
"$",
"aggregateClass",
".",
"' must implement '",
".",
"AggregateInterface",
"::",
"class",
")",
";",
"}",
"}",
"catch",
"(",
"AggregateException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"$",
"uuid",
",",
"$",
"e",
")",
")",
";",
"}",
"return",
"$",
"aggregate",
";",
"}"
] |
Builds an aggregate from a provided Uuid and Aggregate class.
@param string $uuid
@param string $aggregateClass
@param int|null $max_version
@param int|null $user
@return AggregateInterface
|
[
"Builds",
"an",
"aggregate",
"from",
"a",
"provided",
"Uuid",
"and",
"Aggregate",
"class",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/AggregateFactory.php#L76-L136
|
225,027
|
RevisionTen/cqrs
|
Services/AggregateFactory.php
|
AggregateFactory.loadFromHistory
|
public function loadFromHistory(AggregateInterface $aggregate, array $eventStreamObjects): AggregateInterface
{
// Arrays start at zero ;)
$count = \count($eventStreamObjects) - 1;
/**
* Get events and replay them.
*
* @var EventStreamObject $eventStreamObject
*/
foreach ($eventStreamObjects as $key => $eventStreamObject) {
$uuid = $eventStreamObject->getUuid();
// Check if the uuid of the provided Event Stream Object matches.
if ($uuid !== $aggregate->getUuid()) {
continue;
}
if (0 === $key && null === $aggregate->getCreated()) {
// Set Created from first EventStreamObject.
$aggregate->setCreated($eventStreamObject->getCreated());
}
if ($key === $count) {
// Set Modified from last EventStreamObject.
$aggregate->setModified($eventStreamObject->getCreated());
}
$event = EventStore::buildEventFromEventStreamObject($eventStreamObject);
$aggregate = $this->apply($aggregate, $event);
// Update the Aggregate history.
$aggregate->addToHistory([
'version' => $eventStreamObject->getVersion(),
'message' => $eventStreamObject->getMessage(),
'created' => $eventStreamObject->getCreated(),
'payload' => $eventStreamObject->getPayload(),
]);
}
return $this->applyChanges($aggregate);
}
|
php
|
public function loadFromHistory(AggregateInterface $aggregate, array $eventStreamObjects): AggregateInterface
{
// Arrays start at zero ;)
$count = \count($eventStreamObjects) - 1;
/**
* Get events and replay them.
*
* @var EventStreamObject $eventStreamObject
*/
foreach ($eventStreamObjects as $key => $eventStreamObject) {
$uuid = $eventStreamObject->getUuid();
// Check if the uuid of the provided Event Stream Object matches.
if ($uuid !== $aggregate->getUuid()) {
continue;
}
if (0 === $key && null === $aggregate->getCreated()) {
// Set Created from first EventStreamObject.
$aggregate->setCreated($eventStreamObject->getCreated());
}
if ($key === $count) {
// Set Modified from last EventStreamObject.
$aggregate->setModified($eventStreamObject->getCreated());
}
$event = EventStore::buildEventFromEventStreamObject($eventStreamObject);
$aggregate = $this->apply($aggregate, $event);
// Update the Aggregate history.
$aggregate->addToHistory([
'version' => $eventStreamObject->getVersion(),
'message' => $eventStreamObject->getMessage(),
'created' => $eventStreamObject->getCreated(),
'payload' => $eventStreamObject->getPayload(),
]);
}
return $this->applyChanges($aggregate);
}
|
[
"public",
"function",
"loadFromHistory",
"(",
"AggregateInterface",
"$",
"aggregate",
",",
"array",
"$",
"eventStreamObjects",
")",
":",
"AggregateInterface",
"{",
"// Arrays start at zero ;)",
"$",
"count",
"=",
"\\",
"count",
"(",
"$",
"eventStreamObjects",
")",
"-",
"1",
";",
"/**\n * Get events and replay them.\n *\n * @var EventStreamObject $eventStreamObject\n */",
"foreach",
"(",
"$",
"eventStreamObjects",
"as",
"$",
"key",
"=>",
"$",
"eventStreamObject",
")",
"{",
"$",
"uuid",
"=",
"$",
"eventStreamObject",
"->",
"getUuid",
"(",
")",
";",
"// Check if the uuid of the provided Event Stream Object matches.",
"if",
"(",
"$",
"uuid",
"!==",
"$",
"aggregate",
"->",
"getUuid",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"0",
"===",
"$",
"key",
"&&",
"null",
"===",
"$",
"aggregate",
"->",
"getCreated",
"(",
")",
")",
"{",
"// Set Created from first EventStreamObject.",
"$",
"aggregate",
"->",
"setCreated",
"(",
"$",
"eventStreamObject",
"->",
"getCreated",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"$",
"count",
")",
"{",
"// Set Modified from last EventStreamObject.",
"$",
"aggregate",
"->",
"setModified",
"(",
"$",
"eventStreamObject",
"->",
"getCreated",
"(",
")",
")",
";",
"}",
"$",
"event",
"=",
"EventStore",
"::",
"buildEventFromEventStreamObject",
"(",
"$",
"eventStreamObject",
")",
";",
"$",
"aggregate",
"=",
"$",
"this",
"->",
"apply",
"(",
"$",
"aggregate",
",",
"$",
"event",
")",
";",
"// Update the Aggregate history.",
"$",
"aggregate",
"->",
"addToHistory",
"(",
"[",
"'version'",
"=>",
"$",
"eventStreamObject",
"->",
"getVersion",
"(",
")",
",",
"'message'",
"=>",
"$",
"eventStreamObject",
"->",
"getMessage",
"(",
")",
",",
"'created'",
"=>",
"$",
"eventStreamObject",
"->",
"getCreated",
"(",
")",
",",
"'payload'",
"=>",
"$",
"eventStreamObject",
"->",
"getPayload",
"(",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"applyChanges",
"(",
"$",
"aggregate",
")",
";",
"}"
] |
Load an Aggregate from provided Event Stream Objects.
@param AggregateInterface $aggregate
@param array $eventStreamObjects
@return AggregateInterface
|
[
"Load",
"an",
"Aggregate",
"from",
"provided",
"Event",
"Stream",
"Objects",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/AggregateFactory.php#L157-L199
|
225,028
|
RevisionTen/cqrs
|
Services/AggregateFactory.php
|
AggregateFactory.loadFromSnapshot
|
public function loadFromSnapshot(AggregateInterface $aggregate, Snapshot $snapshot): AggregateInterface
{
$snapshotData = $snapshot->getPayload();
$aggregate->setVersion($snapshot->getVersion());
$aggregate->setSnapshotVersion($snapshot->getVersion());
$aggregate->setCreated($snapshot->getAggregateCreated());
$aggregate->setModified($snapshot->getAggregateModified());
$aggregate->setUuid($snapshot->getUuid());
$aggregate->setHistory($snapshot->getHistory());
// Load data from other public properties.
$properties = get_object_vars($aggregate);
foreach ($properties as $property => $existingValue) {
// Skip Modified and Created public properties.
if ('created' === $property || 'modified' === $property) {
continue;
}
// Todo: Convert json date to php DateTime.
if (isset($snapshotData[$property])) {
$aggregate->{$property} = $snapshotData[$property];
}
}
return $aggregate;
}
|
php
|
public function loadFromSnapshot(AggregateInterface $aggregate, Snapshot $snapshot): AggregateInterface
{
$snapshotData = $snapshot->getPayload();
$aggregate->setVersion($snapshot->getVersion());
$aggregate->setSnapshotVersion($snapshot->getVersion());
$aggregate->setCreated($snapshot->getAggregateCreated());
$aggregate->setModified($snapshot->getAggregateModified());
$aggregate->setUuid($snapshot->getUuid());
$aggregate->setHistory($snapshot->getHistory());
// Load data from other public properties.
$properties = get_object_vars($aggregate);
foreach ($properties as $property => $existingValue) {
// Skip Modified and Created public properties.
if ('created' === $property || 'modified' === $property) {
continue;
}
// Todo: Convert json date to php DateTime.
if (isset($snapshotData[$property])) {
$aggregate->{$property} = $snapshotData[$property];
}
}
return $aggregate;
}
|
[
"public",
"function",
"loadFromSnapshot",
"(",
"AggregateInterface",
"$",
"aggregate",
",",
"Snapshot",
"$",
"snapshot",
")",
":",
"AggregateInterface",
"{",
"$",
"snapshotData",
"=",
"$",
"snapshot",
"->",
"getPayload",
"(",
")",
";",
"$",
"aggregate",
"->",
"setVersion",
"(",
"$",
"snapshot",
"->",
"getVersion",
"(",
")",
")",
";",
"$",
"aggregate",
"->",
"setSnapshotVersion",
"(",
"$",
"snapshot",
"->",
"getVersion",
"(",
")",
")",
";",
"$",
"aggregate",
"->",
"setCreated",
"(",
"$",
"snapshot",
"->",
"getAggregateCreated",
"(",
")",
")",
";",
"$",
"aggregate",
"->",
"setModified",
"(",
"$",
"snapshot",
"->",
"getAggregateModified",
"(",
")",
")",
";",
"$",
"aggregate",
"->",
"setUuid",
"(",
"$",
"snapshot",
"->",
"getUuid",
"(",
")",
")",
";",
"$",
"aggregate",
"->",
"setHistory",
"(",
"$",
"snapshot",
"->",
"getHistory",
"(",
")",
")",
";",
"// Load data from other public properties.",
"$",
"properties",
"=",
"get_object_vars",
"(",
"$",
"aggregate",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
"$",
"existingValue",
")",
"{",
"// Skip Modified and Created public properties.",
"if",
"(",
"'created'",
"===",
"$",
"property",
"||",
"'modified'",
"===",
"$",
"property",
")",
"{",
"continue",
";",
"}",
"// Todo: Convert json date to php DateTime.",
"if",
"(",
"isset",
"(",
"$",
"snapshotData",
"[",
"$",
"property",
"]",
")",
")",
"{",
"$",
"aggregate",
"->",
"{",
"$",
"property",
"}",
"=",
"$",
"snapshotData",
"[",
"$",
"property",
"]",
";",
"}",
"}",
"return",
"$",
"aggregate",
";",
"}"
] |
Loads the Aggregate from a Snapshot.
@param AggregateInterface $aggregate
@param Snapshot $snapshot
@return AggregateInterface
|
[
"Loads",
"the",
"Aggregate",
"from",
"a",
"Snapshot",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/AggregateFactory.php#L209-L236
|
225,029
|
RevisionTen/cqrs
|
Services/AggregateFactory.php
|
AggregateFactory.applyChanges
|
public function applyChanges(AggregateInterface $aggregate): AggregateInterface
{
// Execute the handlers of pending Events.
/**
* @var EventInterface $event
*/
foreach ($aggregate->getPendingEvents() as $event) {
/**
* Get Handler for Command.
*
* @var HandlerInterface $handler
*/
$handlerClass = $event->getCommand()->getHandlerClass();
$handler = new $handlerClass($this->messageBus, $this);
$aggregate = $handler->executeHandler($event->getCommand(), $aggregate);
}
// Clear pending events.
$aggregate->setPendingEvents([]);
return $aggregate;
}
|
php
|
public function applyChanges(AggregateInterface $aggregate): AggregateInterface
{
// Execute the handlers of pending Events.
/**
* @var EventInterface $event
*/
foreach ($aggregate->getPendingEvents() as $event) {
/**
* Get Handler for Command.
*
* @var HandlerInterface $handler
*/
$handlerClass = $event->getCommand()->getHandlerClass();
$handler = new $handlerClass($this->messageBus, $this);
$aggregate = $handler->executeHandler($event->getCommand(), $aggregate);
}
// Clear pending events.
$aggregate->setPendingEvents([]);
return $aggregate;
}
|
[
"public",
"function",
"applyChanges",
"(",
"AggregateInterface",
"$",
"aggregate",
")",
":",
"AggregateInterface",
"{",
"// Execute the handlers of pending Events.",
"/**\n * @var EventInterface $event\n */",
"foreach",
"(",
"$",
"aggregate",
"->",
"getPendingEvents",
"(",
")",
"as",
"$",
"event",
")",
"{",
"/**\n * Get Handler for Command.\n *\n * @var HandlerInterface $handler\n */",
"$",
"handlerClass",
"=",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getHandlerClass",
"(",
")",
";",
"$",
"handler",
"=",
"new",
"$",
"handlerClass",
"(",
"$",
"this",
"->",
"messageBus",
",",
"$",
"this",
")",
";",
"$",
"aggregate",
"=",
"$",
"handler",
"->",
"executeHandler",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
",",
"$",
"aggregate",
")",
";",
"}",
"// Clear pending events.",
"$",
"aggregate",
"->",
"setPendingEvents",
"(",
"[",
"]",
")",
";",
"return",
"$",
"aggregate",
";",
"}"
] |
Execute the Handlers of pending Events on Aggregate.
This changes the state of the Aggregate.
@param AggregateInterface $aggregate
@return AggregateInterface
|
[
"Execute",
"the",
"Handlers",
"of",
"pending",
"Events",
"on",
"Aggregate",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/AggregateFactory.php#L247-L268
|
225,030
|
RevisionTen/cqrs
|
Services/AggregateFactory.php
|
AggregateFactory.apply
|
public function apply(AggregateInterface $aggregate, EventInterface $event): AggregateInterface
{
// Increase version on each apply call.
$aggregate->setVersion($event->getCommand()->getOnVersion() + 1);
// Add Event to pending Events.
return $aggregate->addPendingEvent($event);
}
|
php
|
public function apply(AggregateInterface $aggregate, EventInterface $event): AggregateInterface
{
// Increase version on each apply call.
$aggregate->setVersion($event->getCommand()->getOnVersion() + 1);
// Add Event to pending Events.
return $aggregate->addPendingEvent($event);
}
|
[
"public",
"function",
"apply",
"(",
"AggregateInterface",
"$",
"aggregate",
",",
"EventInterface",
"$",
"event",
")",
":",
"AggregateInterface",
"{",
"// Increase version on each apply call.",
"$",
"aggregate",
"->",
"setVersion",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getOnVersion",
"(",
")",
"+",
"1",
")",
";",
"// Add Event to pending Events.",
"return",
"$",
"aggregate",
"->",
"addPendingEvent",
"(",
"$",
"event",
")",
";",
"}"
] |
Adds an Event to the Aggregates pending Events.
Events added here will be change the state of the Aggregate
when applyChanges() is called on the Aggregate.
@param AggregateInterface $aggregate
@param EventInterface $event
@return AggregateInterface
|
[
"Adds",
"an",
"Event",
"to",
"the",
"Aggregates",
"pending",
"Events",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/AggregateFactory.php#L281-L288
|
225,031
|
sopinetchat/SopinetChatBundle
|
Entity/ChatRepository.php
|
ChatRepository.enabledChat
|
public function enabledChat(Chat $chat){
$em = $this->getEntityManager();
$chat->setEnabled(true);
$em->persist($chat);
$em->flush();
}
|
php
|
public function enabledChat(Chat $chat){
$em = $this->getEntityManager();
$chat->setEnabled(true);
$em->persist($chat);
$em->flush();
}
|
[
"public",
"function",
"enabledChat",
"(",
"Chat",
"$",
"chat",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"chat",
"->",
"setEnabled",
"(",
"true",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"chat",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}"
] |
Function to enabled chat
@param Chat $chat
|
[
"Function",
"to",
"enabled",
"chat"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Entity/ChatRepository.php#L73-L81
|
225,032
|
cmsgears/module-cms
|
common/components/Factory.php
|
Factory.registerResourceServices
|
public function registerResourceServices() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IFormService', 'cmsgears\cms\common\services\resources\FormService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ICategoryService', 'cmsgears\cms\common\services\resources\CategoryService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ITagService', 'cmsgears\cms\common\services\resources\TagService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IPageMetaService', 'cmsgears\cms\common\services\resources\PageMetaService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IModelContentService', 'cmsgears\cms\common\services\resources\ModelContentService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ILinkService', 'cmsgears\cms\common\services\resources\LinkService' );
}
|
php
|
public function registerResourceServices() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IFormService', 'cmsgears\cms\common\services\resources\FormService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ICategoryService', 'cmsgears\cms\common\services\resources\CategoryService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ITagService', 'cmsgears\cms\common\services\resources\TagService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IPageMetaService', 'cmsgears\cms\common\services\resources\PageMetaService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\IModelContentService', 'cmsgears\cms\common\services\resources\ModelContentService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\resources\ILinkService', 'cmsgears\cms\common\services\resources\LinkService' );
}
|
[
"public",
"function",
"registerResourceServices",
"(",
")",
"{",
"$",
"factory",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"getContainer",
"(",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\IFormService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\FormService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\ICategoryService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\CategoryService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\ITagService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\TagService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\IPageMetaService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\PageMetaService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\IModelContentService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\ModelContentService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\resources\\ILinkService'",
",",
"'cmsgears\\cms\\common\\services\\resources\\LinkService'",
")",
";",
"}"
] |
Registers resource services.
|
[
"Registers",
"resource",
"services",
"."
] |
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
|
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/components/Factory.php#L68-L80
|
225,033
|
cmsgears/module-cms
|
common/components/Factory.php
|
Factory.registerMapperServices
|
public function registerMapperServices() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelCategoryService', 'cmsgears\cms\common\services\mappers\ModelCategoryService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelTagService', 'cmsgears\cms\common\services\mappers\ModelTagService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IPageFollowerService', 'cmsgears\cms\common\services\mappers\PageFollowerService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelElementService', 'cmsgears\cms\common\services\mappers\ModelElementService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelElementService', 'cmsgears\cms\common\services\mappers\ModelElementService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelBlockService', 'cmsgears\cms\common\services\mappers\ModelBlockService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelLinkService', 'cmsgears\cms\common\services\mappers\ModelLinkService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelWidgetService', 'cmsgears\cms\common\services\mappers\ModelWidgetService' );
}
|
php
|
public function registerMapperServices() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelCategoryService', 'cmsgears\cms\common\services\mappers\ModelCategoryService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelTagService', 'cmsgears\cms\common\services\mappers\ModelTagService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IPageFollowerService', 'cmsgears\cms\common\services\mappers\PageFollowerService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelElementService', 'cmsgears\cms\common\services\mappers\ModelElementService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelElementService', 'cmsgears\cms\common\services\mappers\ModelElementService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelBlockService', 'cmsgears\cms\common\services\mappers\ModelBlockService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelLinkService', 'cmsgears\cms\common\services\mappers\ModelLinkService' );
$factory->set( 'cmsgears\cms\common\services\interfaces\mappers\IModelWidgetService', 'cmsgears\cms\common\services\mappers\ModelWidgetService' );
}
|
[
"public",
"function",
"registerMapperServices",
"(",
")",
"{",
"$",
"factory",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"getContainer",
"(",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelCategoryService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelCategoryService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelTagService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelTagService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IPageFollowerService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\PageFollowerService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelElementService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelElementService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelElementService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelElementService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelBlockService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelBlockService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelLinkService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelLinkService'",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'cmsgears\\cms\\common\\services\\interfaces\\mappers\\IModelWidgetService'",
",",
"'cmsgears\\cms\\common\\services\\mappers\\ModelWidgetService'",
")",
";",
"}"
] |
Registers mapper services.
|
[
"Registers",
"mapper",
"services",
"."
] |
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
|
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/components/Factory.php#L85-L102
|
225,034
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Compiler/MinkExtensionBaseUrlPass.php
|
MinkExtensionBaseUrlPass.process
|
public function process(ContainerBuilder $container)
{
$frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
global $_FILE_TO_URL_MAPPING;
if($container->getParameter('behat.mink.base_url')) {
// If base_url is already defined, also set it in the SilverStripe mapping
$_FILE_TO_URL_MAPPING[dirname($frameworkPath)] = $container->getParameter('behat.mink.base_url');
} else if($envPath = $this->findEnvironmentConfigFile($frameworkPath)) {
// Otherwise try to retrieve it from _ss_environment
include_once $envPath;
if(
isset($_FILE_TO_URL_MAPPING)
&& !($container->hasParameter('behat.mink.base_url') && $container->getParameter('behat.mink.base_url'))
) {
$baseUrl = $this->findBaseUrlFromMapping(dirname($frameworkPath), $_FILE_TO_URL_MAPPING);
if($baseUrl) $container->setParameter('behat.mink.base_url', $baseUrl);
}
}
if(!$container->getParameter('behat.mink.base_url')) {
throw new \InvalidArgumentException(
'"base_url" not configured. Please specify it in your behat.yml configuration, ' .
'or in your _ss_environment.php configuration through $_FILE_TO_URL_MAPPING'
);
}
// The Behat\MinkExtension\Extension class copies configuration into an internal hash,
// we need to follow this pattern to propagate our changes.
$parameters = $container->getParameter('behat.mink.parameters');
$parameters['base_url'] = $container->getParameter('behat.mink.base_url');
$container->setParameter('behat.mink.parameters', $parameters);
}
|
php
|
public function process(ContainerBuilder $container)
{
$frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
global $_FILE_TO_URL_MAPPING;
if($container->getParameter('behat.mink.base_url')) {
// If base_url is already defined, also set it in the SilverStripe mapping
$_FILE_TO_URL_MAPPING[dirname($frameworkPath)] = $container->getParameter('behat.mink.base_url');
} else if($envPath = $this->findEnvironmentConfigFile($frameworkPath)) {
// Otherwise try to retrieve it from _ss_environment
include_once $envPath;
if(
isset($_FILE_TO_URL_MAPPING)
&& !($container->hasParameter('behat.mink.base_url') && $container->getParameter('behat.mink.base_url'))
) {
$baseUrl = $this->findBaseUrlFromMapping(dirname($frameworkPath), $_FILE_TO_URL_MAPPING);
if($baseUrl) $container->setParameter('behat.mink.base_url', $baseUrl);
}
}
if(!$container->getParameter('behat.mink.base_url')) {
throw new \InvalidArgumentException(
'"base_url" not configured. Please specify it in your behat.yml configuration, ' .
'or in your _ss_environment.php configuration through $_FILE_TO_URL_MAPPING'
);
}
// The Behat\MinkExtension\Extension class copies configuration into an internal hash,
// we need to follow this pattern to propagate our changes.
$parameters = $container->getParameter('behat.mink.parameters');
$parameters['base_url'] = $container->getParameter('behat.mink.base_url');
$container->setParameter('behat.mink.parameters', $parameters);
}
|
[
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"frameworkPath",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.silverstripe_extension.framework_path'",
")",
";",
"global",
"$",
"_FILE_TO_URL_MAPPING",
";",
"if",
"(",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.base_url'",
")",
")",
"{",
"// If base_url is already defined, also set it in the SilverStripe mapping",
"$",
"_FILE_TO_URL_MAPPING",
"[",
"dirname",
"(",
"$",
"frameworkPath",
")",
"]",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.base_url'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"envPath",
"=",
"$",
"this",
"->",
"findEnvironmentConfigFile",
"(",
"$",
"frameworkPath",
")",
")",
"{",
"// Otherwise try to retrieve it from _ss_environment",
"include_once",
"$",
"envPath",
";",
"if",
"(",
"isset",
"(",
"$",
"_FILE_TO_URL_MAPPING",
")",
"&&",
"!",
"(",
"$",
"container",
"->",
"hasParameter",
"(",
"'behat.mink.base_url'",
")",
"&&",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.base_url'",
")",
")",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"findBaseUrlFromMapping",
"(",
"dirname",
"(",
"$",
"frameworkPath",
")",
",",
"$",
"_FILE_TO_URL_MAPPING",
")",
";",
"if",
"(",
"$",
"baseUrl",
")",
"$",
"container",
"->",
"setParameter",
"(",
"'behat.mink.base_url'",
",",
"$",
"baseUrl",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.base_url'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'\"base_url\" not configured. Please specify it in your behat.yml configuration, '",
".",
"'or in your _ss_environment.php configuration through $_FILE_TO_URL_MAPPING'",
")",
";",
"}",
"// The Behat\\MinkExtension\\Extension class copies configuration into an internal hash,",
"// we need to follow this pattern to propagate our changes.",
"$",
"parameters",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.parameters'",
")",
";",
"$",
"parameters",
"[",
"'base_url'",
"]",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'behat.mink.base_url'",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'behat.mink.parameters'",
",",
"$",
"parameters",
")",
";",
"}"
] |
Passes MinkExtension's base_url parameter
@param ContainerBuilder $container
|
[
"Passes",
"MinkExtension",
"s",
"base_url",
"parameter"
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Compiler/MinkExtensionBaseUrlPass.php#L22-L54
|
225,035
|
edineibauer/config
|
public/src/Config/Config.php
|
Config.getEntityNotAllow
|
public static function getEntityNotAllow(): array
{
$file = [];
if (file_exists(PATH_HOME . "public/entity/-entity.json"))
$file = json_decode(file_get_contents(PATH_HOME . "public/entity/-entity.json"), true);
foreach (Helper::listFolder(PATH_HOME . VENDOR) as $lib) {
if (file_exists(PATH_HOME . VENDOR . "{$lib}/public/entity/-entity.json")) {
$json = json_decode(file_get_contents(PATH_HOME . VENDOR . "{$lib}/public/entity/-entity.json"), true);
foreach ($json as $setor => $info) {
foreach ($info as $entity) {
if (file_exists(PATH_HOME . VENDOR . "{$lib}/public/entity/cache/{$entity}.json")) {
if ($setor === "*") {
for ($e = 0; $e < 20; $e++) {
//Adiciona entidade ao setor
if (!isset($file[$e]) || !in_array($entity, $file[$e]))
$file[$e][] = $entity;
}
} else {
//Adiciona entidade ao setor
if (!in_array($entity, $file[$setor]))
$file[$setor][] = $entity;
}
}
}
}
}
}
return $file;
}
|
php
|
public static function getEntityNotAllow(): array
{
$file = [];
if (file_exists(PATH_HOME . "public/entity/-entity.json"))
$file = json_decode(file_get_contents(PATH_HOME . "public/entity/-entity.json"), true);
foreach (Helper::listFolder(PATH_HOME . VENDOR) as $lib) {
if (file_exists(PATH_HOME . VENDOR . "{$lib}/public/entity/-entity.json")) {
$json = json_decode(file_get_contents(PATH_HOME . VENDOR . "{$lib}/public/entity/-entity.json"), true);
foreach ($json as $setor => $info) {
foreach ($info as $entity) {
if (file_exists(PATH_HOME . VENDOR . "{$lib}/public/entity/cache/{$entity}.json")) {
if ($setor === "*") {
for ($e = 0; $e < 20; $e++) {
//Adiciona entidade ao setor
if (!isset($file[$e]) || !in_array($entity, $file[$e]))
$file[$e][] = $entity;
}
} else {
//Adiciona entidade ao setor
if (!in_array($entity, $file[$setor]))
$file[$setor][] = $entity;
}
}
}
}
}
}
return $file;
}
|
[
"public",
"static",
"function",
"getEntityNotAllow",
"(",
")",
":",
"array",
"{",
"$",
"file",
"=",
"[",
"]",
";",
"if",
"(",
"file_exists",
"(",
"PATH_HOME",
".",
"\"public/entity/-entity.json\"",
")",
")",
"$",
"file",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"PATH_HOME",
".",
"\"public/entity/-entity.json\"",
")",
",",
"true",
")",
";",
"foreach",
"(",
"Helper",
"::",
"listFolder",
"(",
"PATH_HOME",
".",
"VENDOR",
")",
"as",
"$",
"lib",
")",
"{",
"if",
"(",
"file_exists",
"(",
"PATH_HOME",
".",
"VENDOR",
".",
"\"{$lib}/public/entity/-entity.json\"",
")",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"PATH_HOME",
".",
"VENDOR",
".",
"\"{$lib}/public/entity/-entity.json\"",
")",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"json",
"as",
"$",
"setor",
"=>",
"$",
"info",
")",
"{",
"foreach",
"(",
"$",
"info",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"file_exists",
"(",
"PATH_HOME",
".",
"VENDOR",
".",
"\"{$lib}/public/entity/cache/{$entity}.json\"",
")",
")",
"{",
"if",
"(",
"$",
"setor",
"===",
"\"*\"",
")",
"{",
"for",
"(",
"$",
"e",
"=",
"0",
";",
"$",
"e",
"<",
"20",
";",
"$",
"e",
"++",
")",
"{",
"//Adiciona entidade ao setor",
"if",
"(",
"!",
"isset",
"(",
"$",
"file",
"[",
"$",
"e",
"]",
")",
"||",
"!",
"in_array",
"(",
"$",
"entity",
",",
"$",
"file",
"[",
"$",
"e",
"]",
")",
")",
"$",
"file",
"[",
"$",
"e",
"]",
"[",
"]",
"=",
"$",
"entity",
";",
"}",
"}",
"else",
"{",
"//Adiciona entidade ao setor",
"if",
"(",
"!",
"in_array",
"(",
"$",
"entity",
",",
"$",
"file",
"[",
"$",
"setor",
"]",
")",
")",
"$",
"file",
"[",
"$",
"setor",
"]",
"[",
"]",
"=",
"$",
"entity",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"file",
";",
"}"
] |
Retorna a lista de entidades bloqueadas por setor
@return array
|
[
"Retorna",
"a",
"lista",
"de",
"entidades",
"bloqueadas",
"por",
"setor"
] |
d4331c657895f89b8f889db6bb121f195166c330
|
https://github.com/edineibauer/config/blob/d4331c657895f89b8f889db6bb121f195166c330/public/src/Config/Config.php#L186-L216
|
225,036
|
n2n/n2n-l10n
|
src/app/n2n/l10n/N2nLocale.php
|
N2nLocale.toWebId
|
public function toWebId(bool $ignoreAliases = false) {
if (!$ignoreAliases && null !== ($alias = self::getWebAliasForN2nLocale($this))) {
return $alias;
}
return mb_strtolower(str_replace('_', '-', $this->getId()));
}
|
php
|
public function toWebId(bool $ignoreAliases = false) {
if (!$ignoreAliases && null !== ($alias = self::getWebAliasForN2nLocale($this))) {
return $alias;
}
return mb_strtolower(str_replace('_', '-', $this->getId()));
}
|
[
"public",
"function",
"toWebId",
"(",
"bool",
"$",
"ignoreAliases",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"ignoreAliases",
"&&",
"null",
"!==",
"(",
"$",
"alias",
"=",
"self",
"::",
"getWebAliasForN2nLocale",
"(",
"$",
"this",
")",
")",
")",
"{",
"return",
"$",
"alias",
";",
"}",
"return",
"mb_strtolower",
"(",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"$",
"this",
"->",
"getId",
"(",
")",
")",
")",
";",
"}"
] |
ISO 639-1 - ISO 3166-1 Alpha 2
@param bool $ignoreAliases
@return string
|
[
"ISO",
"639",
"-",
"1",
"-",
"ISO",
"3166",
"-",
"1",
"Alpha",
"2"
] |
f617ec59e63cd56ecedf44e79fcab0a2019c9772
|
https://github.com/n2n/n2n-l10n/blob/f617ec59e63cd56ecedf44e79fcab0a2019c9772/src/app/n2n/l10n/N2nLocale.php#L113-L119
|
225,037
|
Finesse/MiniDB
|
src/Query.php
|
Query.update
|
public function update(array $values): int
{
try {
$query = (clone $this)->addUpdate($values)->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileUpdate($query);
return $this->database->update($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function update(array $values): int
{
try {
$query = (clone $this)->addUpdate($values)->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileUpdate($query);
return $this->database->update($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"values",
")",
":",
"int",
"{",
"try",
"{",
"$",
"query",
"=",
"(",
"clone",
"$",
"this",
")",
"->",
"addUpdate",
"(",
"$",
"values",
")",
"->",
"apply",
"(",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
";",
"$",
"compiled",
"=",
"$",
"this",
"->",
"database",
"->",
"getGrammar",
"(",
")",
"->",
"compileUpdate",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"database",
"->",
"update",
"(",
"$",
"compiled",
"->",
"getSQL",
"(",
")",
",",
"$",
"compiled",
"->",
"getBindings",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Updates the query target rows. Doesn't modify itself.
@param mixed[]|\Closure[]|self[]|StatementInterface[] $values Fields to update. The indexes are the columns
names, the values are the values.
@return int The number of updated rows
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Updates",
"the",
"query",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Query.php#L53-L62
|
225,038
|
Finesse/MiniDB
|
src/Query.php
|
Query.delete
|
public function delete(): int
{
try {
$query = (clone $this)->setDelete()->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileDelete($query);
return $this->database->delete($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function delete(): int
{
try {
$query = (clone $this)->setDelete()->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileDelete($query);
return $this->database->delete($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"delete",
"(",
")",
":",
"int",
"{",
"try",
"{",
"$",
"query",
"=",
"(",
"clone",
"$",
"this",
")",
"->",
"setDelete",
"(",
")",
"->",
"apply",
"(",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
";",
"$",
"compiled",
"=",
"$",
"this",
"->",
"database",
"->",
"getGrammar",
"(",
")",
"->",
"compileDelete",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"database",
"->",
"delete",
"(",
"$",
"compiled",
"->",
"getSQL",
"(",
")",
",",
"$",
"compiled",
"->",
"getBindings",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Deletes the query target rows. Doesn't modify itself.
@return int The number of deleted rows
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Deletes",
"the",
"query",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Query.php#L73-L82
|
225,039
|
cmsgears/module-cart
|
common/models/resources/CartItem.php
|
CartItem.getTotalPrice
|
public function getTotalPrice( $precision = 2 ) {
$price = ( $this->price - $this->discount ) * $this->purchase;
return round( $price, $precision );
}
|
php
|
public function getTotalPrice( $precision = 2 ) {
$price = ( $this->price - $this->discount ) * $this->purchase;
return round( $price, $precision );
}
|
[
"public",
"function",
"getTotalPrice",
"(",
"$",
"precision",
"=",
"2",
")",
"{",
"$",
"price",
"=",
"(",
"$",
"this",
"->",
"price",
"-",
"$",
"this",
"->",
"discount",
")",
"*",
"$",
"this",
"->",
"purchase",
";",
"return",
"round",
"(",
"$",
"price",
",",
"$",
"precision",
")",
";",
"}"
] |
Returns the total price of the item.
Total Price = ( Unit Price - Unit Discount ) * Purchasing Quantity
@param type $precision
@return type
|
[
"Returns",
"the",
"total",
"price",
"of",
"the",
"item",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/CartItem.php#L282-L287
|
225,040
|
cmsgears/module-cart
|
common/models/resources/CartItem.php
|
CartItem.findByParentCartId
|
public static function findByParentCartId( $parentId, $parentType, $cartId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND cartId=:cid', [ ':pid' => $parentId, ':ptype' => $parentType, ':cid' => $cartId ] )->one();
}
|
php
|
public static function findByParentCartId( $parentId, $parentType, $cartId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND cartId=:cid', [ ':pid' => $parentId, ':ptype' => $parentType, ':cid' => $cartId ] )->one();
}
|
[
"public",
"static",
"function",
"findByParentCartId",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"cartId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'parentId=:pid AND parentType=:ptype AND cartId=:cid'",
",",
"[",
"':pid'",
"=>",
"$",
"parentId",
",",
"':ptype'",
"=>",
"$",
"parentType",
",",
"':cid'",
"=>",
"$",
"cartId",
"]",
")",
"->",
"one",
"(",
")",
";",
"}"
] |
Return the cart item associated with given parent id, parent type and cart id.
@param integer $parentId
@param string $parentType
@param integer $cartId
@return CartItem
|
[
"Return",
"the",
"cart",
"item",
"associated",
"with",
"given",
"parent",
"id",
"parent",
"type",
"and",
"cart",
"id",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/CartItem.php#L352-L355
|
225,041
|
stubbles/stubbles-input
|
src/main/php/broker/param/OneOfParamBroker.php
|
OneOfParamBroker.allowedValues
|
private function allowedValues(Annotation $annotation): array
{
if ($annotation->hasValueByName('allowed')) {
return array_map('trim', explode('|', $annotation->getAllowed()));
} elseif ($annotation->hasValueByName('allowedSource')) {
return call_user_func(array_map('trim', explode(
'::',
str_replace('()', '', $annotation->getAllowedSource())
)));
}
throw new \RuntimeException(
'No list of allowed values in annotation @Request[OneOf] on '
. $annotation->target()
);
}
|
php
|
private function allowedValues(Annotation $annotation): array
{
if ($annotation->hasValueByName('allowed')) {
return array_map('trim', explode('|', $annotation->getAllowed()));
} elseif ($annotation->hasValueByName('allowedSource')) {
return call_user_func(array_map('trim', explode(
'::',
str_replace('()', '', $annotation->getAllowedSource())
)));
}
throw new \RuntimeException(
'No list of allowed values in annotation @Request[OneOf] on '
. $annotation->target()
);
}
|
[
"private",
"function",
"allowedValues",
"(",
"Annotation",
"$",
"annotation",
")",
":",
"array",
"{",
"if",
"(",
"$",
"annotation",
"->",
"hasValueByName",
"(",
"'allowed'",
")",
")",
"{",
"return",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"'|'",
",",
"$",
"annotation",
"->",
"getAllowed",
"(",
")",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"annotation",
"->",
"hasValueByName",
"(",
"'allowedSource'",
")",
")",
"{",
"return",
"call_user_func",
"(",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"'::'",
",",
"str_replace",
"(",
"'()'",
",",
"''",
",",
"$",
"annotation",
"->",
"getAllowedSource",
"(",
")",
")",
")",
")",
")",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No list of allowed values in annotation @Request[OneOf] on '",
".",
"$",
"annotation",
"->",
"target",
"(",
")",
")",
";",
"}"
] |
reads default value
@param \stubbles\reflect\annotation\Annotation $annotation
@return string[]
@throws \RuntimeException
|
[
"reads",
"default",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/OneOfParamBroker.php#L38-L53
|
225,042
|
charlesportwoodii/rpq-client
|
src/Queue.php
|
Queue.pop
|
public function pop() :? Job
{
$key = $this->generateListKey();
$element = $this->getFirstElementFromQueue($key);
if ($element === null) {
return null;
}
// Atomic ZPOP
$this->getClient()->getRedis()->watch($key);
while (!$this->getClient()->getRedis()->multi()->zrem($key, $element)->exec()) {
$element = $this->getFirstElementFromQueue($key);
}
$this->getClient()->getRedis()->unwatch($key);
$ref = \explode(':', $element);
$jobId = \end($ref);
return new Job($this, $jobId);
}
|
php
|
public function pop() :? Job
{
$key = $this->generateListKey();
$element = $this->getFirstElementFromQueue($key);
if ($element === null) {
return null;
}
// Atomic ZPOP
$this->getClient()->getRedis()->watch($key);
while (!$this->getClient()->getRedis()->multi()->zrem($key, $element)->exec()) {
$element = $this->getFirstElementFromQueue($key);
}
$this->getClient()->getRedis()->unwatch($key);
$ref = \explode(':', $element);
$jobId = \end($ref);
return new Job($this, $jobId);
}
|
[
"public",
"function",
"pop",
"(",
")",
":",
"?",
"Job",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"generateListKey",
"(",
")",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"getFirstElementFromQueue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"element",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// Atomic ZPOP",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedis",
"(",
")",
"->",
"watch",
"(",
"$",
"key",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedis",
"(",
")",
"->",
"multi",
"(",
")",
"->",
"zrem",
"(",
"$",
"key",
",",
"$",
"element",
")",
"->",
"exec",
"(",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"getFirstElementFromQueue",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedis",
"(",
")",
"->",
"unwatch",
"(",
"$",
"key",
")",
";",
"$",
"ref",
"=",
"\\",
"explode",
"(",
"':'",
",",
"$",
"element",
")",
";",
"$",
"jobId",
"=",
"\\",
"end",
"(",
"$",
"ref",
")",
";",
"return",
"new",
"Job",
"(",
"$",
"this",
",",
"$",
"jobId",
")",
";",
"}"
] |
Pops the highest priority item off of the priority queue
@return Job
|
[
"Pops",
"the",
"highest",
"priority",
"item",
"off",
"of",
"the",
"priority",
"queue"
] |
9419cfe5c30d35ea54ce8faba7545daea2312e0f
|
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue.php#L115-L135
|
225,043
|
charlesportwoodii/rpq-client
|
src/Queue.php
|
Queue.getFirstElementFromQueue
|
private function getFirstElementFromQueue($key) :? string
{
$result = $this->getClient()->getRedis()->zrevrange($key, 0, 0);
if (empty($result)) {
return null;
}
return $result[0];
}
|
php
|
private function getFirstElementFromQueue($key) :? string
{
$result = $this->getClient()->getRedis()->zrevrange($key, 0, 0);
if (empty($result)) {
return null;
}
return $result[0];
}
|
[
"private",
"function",
"getFirstElementFromQueue",
"(",
"$",
"key",
")",
":",
"?",
"string",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedis",
"(",
")",
"->",
"zrevrange",
"(",
"$",
"key",
",",
"0",
",",
"0",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"result",
"[",
"0",
"]",
";",
"}"
] |
Gets the head element off of the list
@param string $key
@return array
|
[
"Gets",
"the",
"head",
"element",
"off",
"of",
"the",
"list"
] |
9419cfe5c30d35ea54ce8faba7545daea2312e0f
|
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue.php#L176-L184
|
225,044
|
charlesportwoodii/rpq-client
|
src/Queue.php
|
Queue.generateListKey
|
public function generateListKey() : string
{
$filter = [
$this->getClient()->getNamespace(),
'queue',
\str_replace(':', '.', $this->getName())
];
$parts = \array_filter($filter, 'strlen');
return \implode(':', $parts);
}
|
php
|
public function generateListKey() : string
{
$filter = [
$this->getClient()->getNamespace(),
'queue',
\str_replace(':', '.', $this->getName())
];
$parts = \array_filter($filter, 'strlen');
return \implode(':', $parts);
}
|
[
"public",
"function",
"generateListKey",
"(",
")",
":",
"string",
"{",
"$",
"filter",
"=",
"[",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getNamespace",
"(",
")",
",",
"'queue'",
",",
"\\",
"str_replace",
"(",
"':'",
",",
"'.'",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"]",
";",
"$",
"parts",
"=",
"\\",
"array_filter",
"(",
"$",
"filter",
",",
"'strlen'",
")",
";",
"return",
"\\",
"implode",
"(",
"':'",
",",
"$",
"parts",
")",
";",
"}"
] |
Generates a unique key for the job
@return string
|
[
"Generates",
"a",
"unique",
"key",
"for",
"the",
"job"
] |
9419cfe5c30d35ea54ce8faba7545daea2312e0f
|
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue.php#L191-L200
|
225,045
|
charlesportwoodii/rpq-client
|
src/Queue.php
|
Queue.getStatsByType
|
public function getStatsByType(string $date, string $type) :? array
{
if ($this->isValidDate($date)) {
$results = $this->getClient()->getRedis()->hgetall($date . '_' . $type);
\ksort($results);
return $results;
}
return null;
}
|
php
|
public function getStatsByType(string $date, string $type) :? array
{
if ($this->isValidDate($date)) {
$results = $this->getClient()->getRedis()->hgetall($date . '_' . $type);
\ksort($results);
return $results;
}
return null;
}
|
[
"public",
"function",
"getStatsByType",
"(",
"string",
"$",
"date",
",",
"string",
"$",
"type",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidDate",
"(",
"$",
"date",
")",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"getRedis",
"(",
")",
"->",
"hgetall",
"(",
"$",
"date",
".",
"'_'",
".",
"$",
"type",
")",
";",
"\\",
"ksort",
"(",
"$",
"results",
")",
";",
"return",
"$",
"results",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns stats by a given type
@param string $date
@param string $type
@return array
|
[
"Returns",
"stats",
"by",
"a",
"given",
"type"
] |
9419cfe5c30d35ea54ce8faba7545daea2312e0f
|
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue.php#L209-L218
|
225,046
|
charlesportwoodii/rpq-client
|
src/Queue.php
|
Queue.isValidDate
|
private function isValidDate(string $date, string $format = 'Y-m-d') : bool
{
$d = DateTime::createFromFormat($format, $date);
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
return $d && $d->format($format) === $date;
}
|
php
|
private function isValidDate(string $date, string $format = 'Y-m-d') : bool
{
$d = DateTime::createFromFormat($format, $date);
// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
return $d && $d->format($format) === $date;
}
|
[
"private",
"function",
"isValidDate",
"(",
"string",
"$",
"date",
",",
"string",
"$",
"format",
"=",
"'Y-m-d'",
")",
":",
"bool",
"{",
"$",
"d",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"date",
")",
";",
"// The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.",
"return",
"$",
"d",
"&&",
"$",
"d",
"->",
"format",
"(",
"$",
"format",
")",
"===",
"$",
"date",
";",
"}"
] |
Returns true if the date is valid
@param string $date
@param string $format
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"date",
"is",
"valid"
] |
9419cfe5c30d35ea54ce8faba7545daea2312e0f
|
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue.php#L227-L232
|
225,047
|
DrNixx/yii2-onix
|
src/widgets/InputWidget.php
|
InputWidget.initInputWidget
|
protected function initInputWidget()
{
$this->initI18N(__DIR__, 'onix-core');
if (!isset($this->language)) {
$this->language = Yii::$app->language;
}
$this->_lang = Env::getLang($this->language);
if ($this->pluginLoading) {
$this->_loadIndicator = static::getLoadProgress();
}
if ($this->hasModel()) {
$this->name = !isset($this->options['name']) ? Html::getInputName($this->model, $this->attribute) : $this->options['name'];
$this->value = !isset($this->options['value'])? Html::getAttributeValue($this->model, $this->attribute) : $this->options['value'];
}
$this->initDisability($this->options);
}
|
php
|
protected function initInputWidget()
{
$this->initI18N(__DIR__, 'onix-core');
if (!isset($this->language)) {
$this->language = Yii::$app->language;
}
$this->_lang = Env::getLang($this->language);
if ($this->pluginLoading) {
$this->_loadIndicator = static::getLoadProgress();
}
if ($this->hasModel()) {
$this->name = !isset($this->options['name']) ? Html::getInputName($this->model, $this->attribute) : $this->options['name'];
$this->value = !isset($this->options['value'])? Html::getAttributeValue($this->model, $this->attribute) : $this->options['value'];
}
$this->initDisability($this->options);
}
|
[
"protected",
"function",
"initInputWidget",
"(",
")",
"{",
"$",
"this",
"->",
"initI18N",
"(",
"__DIR__",
",",
"'onix-core'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"language",
")",
")",
"{",
"$",
"this",
"->",
"language",
"=",
"Yii",
"::",
"$",
"app",
"->",
"language",
";",
"}",
"$",
"this",
"->",
"_lang",
"=",
"Env",
"::",
"getLang",
"(",
"$",
"this",
"->",
"language",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pluginLoading",
")",
"{",
"$",
"this",
"->",
"_loadIndicator",
"=",
"static",
"::",
"getLoadProgress",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasModel",
"(",
")",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
")",
"?",
"Html",
"::",
"getInputName",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"attribute",
")",
":",
"$",
"this",
"->",
"options",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"value",
"=",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'value'",
"]",
")",
"?",
"Html",
"::",
"getAttributeValue",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"attribute",
")",
":",
"$",
"this",
"->",
"options",
"[",
"'value'",
"]",
";",
"}",
"$",
"this",
"->",
"initDisability",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}"
] |
Initializes the input widget.
|
[
"Initializes",
"the",
"input",
"widget",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/InputWidget.php#L185-L204
|
225,048
|
DrNixx/yii2-onix
|
src/widgets/InputWidget.php
|
InputWidget.initDisability
|
protected function initDisability(&$options)
{
if ($this->disabled && !isset($options['disabled'])) {
$options['disabled'] = true;
}
if ($this->readonly && !isset($options['readonly'])) {
$options['readonly'] = true;
}
}
|
php
|
protected function initDisability(&$options)
{
if ($this->disabled && !isset($options['disabled'])) {
$options['disabled'] = true;
}
if ($this->readonly && !isset($options['readonly'])) {
$options['readonly'] = true;
}
}
|
[
"protected",
"function",
"initDisability",
"(",
"&",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"disabled",
"&&",
"!",
"isset",
"(",
"$",
"options",
"[",
"'disabled'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'disabled'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"readonly",
"&&",
"!",
"isset",
"(",
"$",
"options",
"[",
"'readonly'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'readonly'",
"]",
"=",
"true",
";",
"}",
"}"
] |
Validates and sets disabled or readonly inputs.
@param array $options the HTML attributes for the input
|
[
"Validates",
"and",
"sets",
"disabled",
"or",
"readonly",
"inputs",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/InputWidget.php#L216-L224
|
225,049
|
DrNixx/yii2-onix
|
src/widgets/InputWidget.php
|
InputWidget.initLanguage
|
protected function initLanguage($property = 'language', $full = false)
{
if (empty($this->pluginOptions[$property])) {
$this->pluginOptions[$property] = $full ? $this->language : $this->_lang;
}
}
|
php
|
protected function initLanguage($property = 'language', $full = false)
{
if (empty($this->pluginOptions[$property])) {
$this->pluginOptions[$property] = $full ? $this->language : $this->_lang;
}
}
|
[
"protected",
"function",
"initLanguage",
"(",
"$",
"property",
"=",
"'language'",
",",
"$",
"full",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"pluginOptions",
"[",
"$",
"property",
"]",
")",
")",
"{",
"$",
"this",
"->",
"pluginOptions",
"[",
"$",
"property",
"]",
"=",
"$",
"full",
"?",
"$",
"this",
"->",
"language",
":",
"$",
"this",
"->",
"_lang",
";",
"}",
"}"
] |
Initialize the plugin language.
@param string $property the name of language property in [[pluginOptions]].
@param boolean $full whether to use the full language string. Defaults to `false`
which is the 2 (or 3) digit ISO-639 format.
Defaults to 'language'.
|
[
"Initialize",
"the",
"plugin",
"language",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/InputWidget.php#L234-L239
|
225,050
|
DrNixx/yii2-onix
|
src/widgets/InputWidget.php
|
InputWidget.setLanguage
|
protected function setLanguage($prefix, $assetPath = null, $filePath = null, $suffix = '.js')
{
$pwd = Env::getCurrentDir($this);
$s = DIRECTORY_SEPARATOR;
if ($assetPath === null) {
$assetPath = "{$pwd}{$s}assets{$s}";
} elseif (substr($assetPath, -1) != $s) {
$assetPath .= $s;
}
if ($filePath === null) {
$filePath = "js{$s}locales{$s}";
} elseif (substr($filePath, -1) != $s) {
$filePath .= $s;
}
$full = $filePath . $prefix . $this->language . $suffix;
$fullLower = $filePath . $prefix . strtolower($this->language) . $suffix;
$short = $filePath . $prefix . $this->_lang . $suffix;
if (Env::fileExists($assetPath . $full)) {
$this->_langFile = $full;
$this->pluginOptions['language'] = $this->language;
} elseif (Env::fileExists($assetPath . $fullLower)) {
$this->_langFile = $fullLower;
$this->pluginOptions['language'] = strtolower($this->language);
} elseif (Env::fileExists($assetPath . $short)) {
$this->_langFile = $short;
$this->pluginOptions['language'] = $this->_lang;
} else {
$this->_langFile = '';
}
$this->_langFile = str_replace($s, '/', $this->_langFile);
}
|
php
|
protected function setLanguage($prefix, $assetPath = null, $filePath = null, $suffix = '.js')
{
$pwd = Env::getCurrentDir($this);
$s = DIRECTORY_SEPARATOR;
if ($assetPath === null) {
$assetPath = "{$pwd}{$s}assets{$s}";
} elseif (substr($assetPath, -1) != $s) {
$assetPath .= $s;
}
if ($filePath === null) {
$filePath = "js{$s}locales{$s}";
} elseif (substr($filePath, -1) != $s) {
$filePath .= $s;
}
$full = $filePath . $prefix . $this->language . $suffix;
$fullLower = $filePath . $prefix . strtolower($this->language) . $suffix;
$short = $filePath . $prefix . $this->_lang . $suffix;
if (Env::fileExists($assetPath . $full)) {
$this->_langFile = $full;
$this->pluginOptions['language'] = $this->language;
} elseif (Env::fileExists($assetPath . $fullLower)) {
$this->_langFile = $fullLower;
$this->pluginOptions['language'] = strtolower($this->language);
} elseif (Env::fileExists($assetPath . $short)) {
$this->_langFile = $short;
$this->pluginOptions['language'] = $this->_lang;
} else {
$this->_langFile = '';
}
$this->_langFile = str_replace($s, '/', $this->_langFile);
}
|
[
"protected",
"function",
"setLanguage",
"(",
"$",
"prefix",
",",
"$",
"assetPath",
"=",
"null",
",",
"$",
"filePath",
"=",
"null",
",",
"$",
"suffix",
"=",
"'.js'",
")",
"{",
"$",
"pwd",
"=",
"Env",
"::",
"getCurrentDir",
"(",
"$",
"this",
")",
";",
"$",
"s",
"=",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"$",
"assetPath",
"===",
"null",
")",
"{",
"$",
"assetPath",
"=",
"\"{$pwd}{$s}assets{$s}\"",
";",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"assetPath",
",",
"-",
"1",
")",
"!=",
"$",
"s",
")",
"{",
"$",
"assetPath",
".=",
"$",
"s",
";",
"}",
"if",
"(",
"$",
"filePath",
"===",
"null",
")",
"{",
"$",
"filePath",
"=",
"\"js{$s}locales{$s}\"",
";",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"filePath",
",",
"-",
"1",
")",
"!=",
"$",
"s",
")",
"{",
"$",
"filePath",
".=",
"$",
"s",
";",
"}",
"$",
"full",
"=",
"$",
"filePath",
".",
"$",
"prefix",
".",
"$",
"this",
"->",
"language",
".",
"$",
"suffix",
";",
"$",
"fullLower",
"=",
"$",
"filePath",
".",
"$",
"prefix",
".",
"strtolower",
"(",
"$",
"this",
"->",
"language",
")",
".",
"$",
"suffix",
";",
"$",
"short",
"=",
"$",
"filePath",
".",
"$",
"prefix",
".",
"$",
"this",
"->",
"_lang",
".",
"$",
"suffix",
";",
"if",
"(",
"Env",
"::",
"fileExists",
"(",
"$",
"assetPath",
".",
"$",
"full",
")",
")",
"{",
"$",
"this",
"->",
"_langFile",
"=",
"$",
"full",
";",
"$",
"this",
"->",
"pluginOptions",
"[",
"'language'",
"]",
"=",
"$",
"this",
"->",
"language",
";",
"}",
"elseif",
"(",
"Env",
"::",
"fileExists",
"(",
"$",
"assetPath",
".",
"$",
"fullLower",
")",
")",
"{",
"$",
"this",
"->",
"_langFile",
"=",
"$",
"fullLower",
";",
"$",
"this",
"->",
"pluginOptions",
"[",
"'language'",
"]",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"language",
")",
";",
"}",
"elseif",
"(",
"Env",
"::",
"fileExists",
"(",
"$",
"assetPath",
".",
"$",
"short",
")",
")",
"{",
"$",
"this",
"->",
"_langFile",
"=",
"$",
"short",
";",
"$",
"this",
"->",
"pluginOptions",
"[",
"'language'",
"]",
"=",
"$",
"this",
"->",
"_lang",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_langFile",
"=",
"''",
";",
"}",
"$",
"this",
"->",
"_langFile",
"=",
"str_replace",
"(",
"$",
"s",
",",
"'/'",
",",
"$",
"this",
"->",
"_langFile",
")",
";",
"}"
] |
Sets the language JS file if it exists.
@param string $prefix the language filename prefix
@param string $assetPath the path to the assets
@param string $filePath the path to the JS file with the file name prefix
@param string $suffix the file name suffix - defaults to '.js'
|
[
"Sets",
"the",
"language",
"JS",
"file",
"if",
"it",
"exists",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/InputWidget.php#L249-L282
|
225,051
|
DrNixx/yii2-onix
|
src/widgets/InputWidget.php
|
InputWidget.getInput
|
protected function getInput($type, $list = false)
{
if ($this->hasModel()) {
$input = 'active' . ucfirst($type);
return $list ?
Html::$input($this->model, $this->attribute, $this->data, $this->options) :
Html::$input($this->model, $this->attribute, $this->options);
}
$input = $type;
$checked = false;
if ($type == 'radio' || $type == 'checkbox') {
$checked = ArrayHelper::remove($this->options, 'checked', '');
if (empty($checked) && !empty($this->value)) {
$checked = ($this->value == 0) ? false : true;
} elseif (empty($checked)) {
$checked = false;
}
}
return $list ?
Html::$input($this->name, $this->value, $this->data, $this->options) :
(($type == 'checkbox' || $type == 'radio') ?
Html::$input($this->name, $checked, $this->options) :
Html::$input($this->name, $this->value, $this->options));
}
|
php
|
protected function getInput($type, $list = false)
{
if ($this->hasModel()) {
$input = 'active' . ucfirst($type);
return $list ?
Html::$input($this->model, $this->attribute, $this->data, $this->options) :
Html::$input($this->model, $this->attribute, $this->options);
}
$input = $type;
$checked = false;
if ($type == 'radio' || $type == 'checkbox') {
$checked = ArrayHelper::remove($this->options, 'checked', '');
if (empty($checked) && !empty($this->value)) {
$checked = ($this->value == 0) ? false : true;
} elseif (empty($checked)) {
$checked = false;
}
}
return $list ?
Html::$input($this->name, $this->value, $this->data, $this->options) :
(($type == 'checkbox' || $type == 'radio') ?
Html::$input($this->name, $checked, $this->options) :
Html::$input($this->name, $this->value, $this->options));
}
|
[
"protected",
"function",
"getInput",
"(",
"$",
"type",
",",
"$",
"list",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasModel",
"(",
")",
")",
"{",
"$",
"input",
"=",
"'active'",
".",
"ucfirst",
"(",
"$",
"type",
")",
";",
"return",
"$",
"list",
"?",
"Html",
"::",
"$",
"input",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"attribute",
",",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"options",
")",
":",
"Html",
"::",
"$",
"input",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"attribute",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
"$",
"input",
"=",
"$",
"type",
";",
"$",
"checked",
"=",
"false",
";",
"if",
"(",
"$",
"type",
"==",
"'radio'",
"||",
"$",
"type",
"==",
"'checkbox'",
")",
"{",
"$",
"checked",
"=",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"this",
"->",
"options",
",",
"'checked'",
",",
"''",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"checked",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"checked",
"=",
"(",
"$",
"this",
"->",
"value",
"==",
"0",
")",
"?",
"false",
":",
"true",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"checked",
")",
")",
"{",
"$",
"checked",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"list",
"?",
"Html",
"::",
"$",
"input",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"options",
")",
":",
"(",
"(",
"$",
"type",
"==",
"'checkbox'",
"||",
"$",
"type",
"==",
"'radio'",
")",
"?",
"Html",
"::",
"$",
"input",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"checked",
",",
"$",
"this",
"->",
"options",
")",
":",
"Html",
"::",
"$",
"input",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"$",
"this",
"->",
"options",
")",
")",
";",
"}"
] |
Generates an input.
@param string $type the input type
@param boolean $list whether the input is of dropdown list type
@return string the rendered input markup
|
[
"Generates",
"an",
"input",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/widgets/InputWidget.php#L292-L317
|
225,052
|
RevisionTen/cqrs
|
Handler/Handler.php
|
Handler.executeHandler
|
public function executeHandler(CommandInterface $command, AggregateInterface $aggregate): AggregateInterface
{
/* Execute method is implemented in final class */
return $this->execute($command, $aggregate);
}
|
php
|
public function executeHandler(CommandInterface $command, AggregateInterface $aggregate): AggregateInterface
{
/* Execute method is implemented in final class */
return $this->execute($command, $aggregate);
}
|
[
"public",
"function",
"executeHandler",
"(",
"CommandInterface",
"$",
"command",
",",
"AggregateInterface",
"$",
"aggregate",
")",
":",
"AggregateInterface",
"{",
"/* Execute method is implemented in final class */",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"command",
",",
"$",
"aggregate",
")",
";",
"}"
] |
A wrapper for the execute function.
@param CommandInterface $command
@param AggregateInterface $aggregate
@return AggregateInterface
|
[
"A",
"wrapper",
"for",
"the",
"execute",
"function",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Handler/Handler.php#L79-L83
|
225,053
|
RevisionTen/cqrs
|
Handler/Handler.php
|
Handler.getAggregate
|
public function getAggregate(string $uuid, string $aggregateClass, int $user): AggregateInterface
{
return $this->aggregateFactory->build($uuid, $aggregateClass, null, $user);
}
|
php
|
public function getAggregate(string $uuid, string $aggregateClass, int $user): AggregateInterface
{
return $this->aggregateFactory->build($uuid, $aggregateClass, null, $user);
}
|
[
"public",
"function",
"getAggregate",
"(",
"string",
"$",
"uuid",
",",
"string",
"$",
"aggregateClass",
",",
"int",
"$",
"user",
")",
":",
"AggregateInterface",
"{",
"return",
"$",
"this",
"->",
"aggregateFactory",
"->",
"build",
"(",
"$",
"uuid",
",",
"$",
"aggregateClass",
",",
"null",
",",
"$",
"user",
")",
";",
"}"
] |
Returns an Aggregate based on the provided uuid.
@param string $uuid
@param string $aggregateClass
@param int $user
@return AggregateInterface
|
[
"Returns",
"an",
"Aggregate",
"based",
"on",
"the",
"provided",
"uuid",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Handler/Handler.php#L94-L97
|
225,054
|
chEbba/LogStock
|
src/Che/LogStock/LoggerFactoryBuilder.php
|
LoggerFactoryBuilder.createDefaultFactory
|
protected function createDefaultFactory()
{
$loader = $this->loader ? : $this->createDefaultLoader();
if ($this->hierarchy) {
$loader = new HierarchicalNameLoader($loader);
}
$rootAdapter = $this->fallbackAdapter ? : $this->createDefaultFallbackAdapter();
return new AdapterLoaderFactory($loader, $rootAdapter);
}
|
php
|
protected function createDefaultFactory()
{
$loader = $this->loader ? : $this->createDefaultLoader();
if ($this->hierarchy) {
$loader = new HierarchicalNameLoader($loader);
}
$rootAdapter = $this->fallbackAdapter ? : $this->createDefaultFallbackAdapter();
return new AdapterLoaderFactory($loader, $rootAdapter);
}
|
[
"protected",
"function",
"createDefaultFactory",
"(",
")",
"{",
"$",
"loader",
"=",
"$",
"this",
"->",
"loader",
"?",
":",
"$",
"this",
"->",
"createDefaultLoader",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hierarchy",
")",
"{",
"$",
"loader",
"=",
"new",
"HierarchicalNameLoader",
"(",
"$",
"loader",
")",
";",
"}",
"$",
"rootAdapter",
"=",
"$",
"this",
"->",
"fallbackAdapter",
"?",
":",
"$",
"this",
"->",
"createDefaultFallbackAdapter",
"(",
")",
";",
"return",
"new",
"AdapterLoaderFactory",
"(",
"$",
"loader",
",",
"$",
"rootAdapter",
")",
";",
"}"
] |
Create default adapter loader with optional hierarchy wrapper
@return LoggerFactory
@see disableHierarchy()
@see loader()
@see fallbackAdapter()
|
[
"Create",
"default",
"adapter",
"loader",
"with",
"optional",
"hierarchy",
"wrapper"
] |
206ee26ed937b0f8857b63a527dd1a6020f52168
|
https://github.com/chEbba/LogStock/blob/206ee26ed937b0f8857b63a527dd1a6020f52168/src/Che/LogStock/LoggerFactoryBuilder.php#L172-L181
|
225,055
|
n2n/n2n-log4php
|
src/app/n2n/log4php/reflection/ReflectionUtils.php
|
ReflectionUtils.setProperty
|
public function setProperty($name, $value) {
if($value === null) {
return;
}
$method = "set" . ucfirst($name);
if(!method_exists($this->obj, $method)) {
throw new \Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
} else {
return call_user_func(array($this->obj, $method), $value);
}
}
|
php
|
public function setProperty($name, $value) {
if($value === null) {
return;
}
$method = "set" . ucfirst($name);
if(!method_exists($this->obj, $method)) {
throw new \Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
} else {
return call_user_func(array($this->obj, $method), $value);
}
}
|
[
"public",
"function",
"setProperty",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"method",
"=",
"\"set\"",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"obj",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Error setting log4php property $name to $value: no method $method in class \"",
".",
"get_class",
"(",
"$",
"this",
"->",
"obj",
")",
".",
"\"!\"",
")",
";",
"}",
"else",
"{",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"obj",
",",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Set a property on this PropertySetter's Object. If successful, this
method will invoke a setter method on the underlying Object. The
setter is the one for the specified property name and the value is
determined partly from the setter argument type and partly from the
value specified in the call to this method.
<p>If the setter expects a String no conversion is necessary.
If it expects an int, then an attempt is made to convert 'value'
to an int using new Integer(value). If the setter expects a boolean,
the conversion is by new Boolean(value).
@param string $name name of the property
@param string $value String value of the property
|
[
"Set",
"a",
"property",
"on",
"this",
"PropertySetter",
"s",
"Object",
".",
"If",
"successful",
"this",
"method",
"will",
"invoke",
"a",
"setter",
"method",
"on",
"the",
"underlying",
"Object",
".",
"The",
"setter",
"is",
"the",
"one",
"for",
"the",
"specified",
"property",
"name",
"and",
"the",
"value",
"is",
"determined",
"partly",
"from",
"the",
"setter",
"argument",
"type",
"and",
"partly",
"from",
"the",
"value",
"specified",
"in",
"the",
"call",
"to",
"this",
"method",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/reflection/ReflectionUtils.php#L103-L115
|
225,056
|
n2n/n2n-l10n
|
src/app/n2n/l10n/MessageContainer.php
|
MessageContainer.add
|
public function add(Message $message, $groupName = null) {
if (!isset($this->messages[$groupName])) {
$this->messages[$groupName] = array();
}
$this->messages[$groupName][] = $message;
}
|
php
|
public function add(Message $message, $groupName = null) {
if (!isset($this->messages[$groupName])) {
$this->messages[$groupName] = array();
}
$this->messages[$groupName][] = $message;
}
|
[
"public",
"function",
"add",
"(",
"Message",
"$",
"message",
",",
"$",
"groupName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"messages",
"[",
"$",
"groupName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"$",
"groupName",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"messages",
"[",
"$",
"groupName",
"]",
"[",
"]",
"=",
"$",
"message",
";",
"}"
] |
adds a Messsage object
@param Message $message the Message object.
@param string $groupName the name of the group, which helps to categorize messages.
|
[
"adds",
"a",
"Messsage",
"object"
] |
f617ec59e63cd56ecedf44e79fcab0a2019c9772
|
https://github.com/n2n/n2n-l10n/blob/f617ec59e63cd56ecedf44e79fcab0a2019c9772/src/app/n2n/l10n/MessageContainer.php#L70-L76
|
225,057
|
n2n/n2n-l10n
|
src/app/n2n/l10n/MessageContainer.php
|
MessageContainer.addAll
|
public function addAll(array $messages, $groupName = null) {
foreach ($messages as $message) {
$this->add($message, $groupName);
}
}
|
php
|
public function addAll(array $messages, $groupName = null) {
foreach ($messages as $message) {
$this->add($message, $groupName);
}
}
|
[
"public",
"function",
"addAll",
"(",
"array",
"$",
"messages",
",",
"$",
"groupName",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"message",
",",
"$",
"groupName",
")",
";",
"}",
"}"
] |
Adds a collection of message objects.
@param array $messages
@param string $groupName
|
[
"Adds",
"a",
"collection",
"of",
"message",
"objects",
"."
] |
f617ec59e63cd56ecedf44e79fcab0a2019c9772
|
https://github.com/n2n/n2n-l10n/blob/f617ec59e63cd56ecedf44e79fcab0a2019c9772/src/app/n2n/l10n/MessageContainer.php#L84-L88
|
225,058
|
czogori/Dami
|
src/Dami/Migration/Api/MigrationApi.php
|
MigrationApi.createTable
|
public function createTable($name, array $options = [])
{
$schema = isset($options['schema']) ? new Schema($options['schema']) : null;
$table = new TableApi($name, $schema, $this->manipulation, $this->actions);
$primaryKey = isset($options['primary_key'])
? new PrimaryKey($options['primary_key'], $table)
: new PrimaryKey(array(), $table);
if (isset($options['primary_key_auto_increment']) && false === $options['primary_key_auto_increment']) {
$primaryKey->disableAutoIncrement();
}
$table->addConstraint($primaryKey);
if (isset($options['comment'])) {
$table->setDescription($options['comment']);
}
$this->actions[] = function () use ($table) {
return $this->manipulation->create($table);
};
return $table;
}
|
php
|
public function createTable($name, array $options = [])
{
$schema = isset($options['schema']) ? new Schema($options['schema']) : null;
$table = new TableApi($name, $schema, $this->manipulation, $this->actions);
$primaryKey = isset($options['primary_key'])
? new PrimaryKey($options['primary_key'], $table)
: new PrimaryKey(array(), $table);
if (isset($options['primary_key_auto_increment']) && false === $options['primary_key_auto_increment']) {
$primaryKey->disableAutoIncrement();
}
$table->addConstraint($primaryKey);
if (isset($options['comment'])) {
$table->setDescription($options['comment']);
}
$this->actions[] = function () use ($table) {
return $this->manipulation->create($table);
};
return $table;
}
|
[
"public",
"function",
"createTable",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"schema",
"=",
"isset",
"(",
"$",
"options",
"[",
"'schema'",
"]",
")",
"?",
"new",
"Schema",
"(",
"$",
"options",
"[",
"'schema'",
"]",
")",
":",
"null",
";",
"$",
"table",
"=",
"new",
"TableApi",
"(",
"$",
"name",
",",
"$",
"schema",
",",
"$",
"this",
"->",
"manipulation",
",",
"$",
"this",
"->",
"actions",
")",
";",
"$",
"primaryKey",
"=",
"isset",
"(",
"$",
"options",
"[",
"'primary_key'",
"]",
")",
"?",
"new",
"PrimaryKey",
"(",
"$",
"options",
"[",
"'primary_key'",
"]",
",",
"$",
"table",
")",
":",
"new",
"PrimaryKey",
"(",
"array",
"(",
")",
",",
"$",
"table",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'primary_key_auto_increment'",
"]",
")",
"&&",
"false",
"===",
"$",
"options",
"[",
"'primary_key_auto_increment'",
"]",
")",
"{",
"$",
"primaryKey",
"->",
"disableAutoIncrement",
"(",
")",
";",
"}",
"$",
"table",
"->",
"addConstraint",
"(",
"$",
"primaryKey",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'comment'",
"]",
")",
")",
"{",
"$",
"table",
"->",
"setDescription",
"(",
"$",
"options",
"[",
"'comment'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"actions",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"table",
")",
"{",
"return",
"$",
"this",
"->",
"manipulation",
"->",
"create",
"(",
"$",
"table",
")",
";",
"}",
";",
"return",
"$",
"table",
";",
"}"
] |
Create new table.
@param string $name Table name.
@param array $options Optional options.
@return CreationTableApi CreationTableApi instance.
|
[
"Create",
"new",
"table",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/MigrationApi.php#L38-L60
|
225,059
|
czogori/Dami
|
src/Dami/Migration/Api/MigrationApi.php
|
MigrationApi.createSchema
|
public function createSchema($name)
{
$schema = new Schema($name);
$this->actions[] = function () use ($schema) {
return $this->manipulation->create($schema);
};
}
|
php
|
public function createSchema($name)
{
$schema = new Schema($name);
$this->actions[] = function () use ($schema) {
return $this->manipulation->create($schema);
};
}
|
[
"public",
"function",
"createSchema",
"(",
"$",
"name",
")",
"{",
"$",
"schema",
"=",
"new",
"Schema",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"actions",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"schema",
")",
"{",
"return",
"$",
"this",
"->",
"manipulation",
"->",
"create",
"(",
"$",
"schema",
")",
";",
"}",
";",
"}"
] |
Create new schema.
@param string $name Schema name.
@return void
|
[
"Create",
"new",
"schema",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/MigrationApi.php#L104-L110
|
225,060
|
czogori/Dami
|
src/Dami/Migration/Api/MigrationApi.php
|
MigrationApi.dropSchema
|
public function dropSchema($name)
{
$schema = new Schema($name);
$this->actions[] = function () use ($schema) {
return $this->manipulation->drop($schema);
};
}
|
php
|
public function dropSchema($name)
{
$schema = new Schema($name);
$this->actions[] = function () use ($schema) {
return $this->manipulation->drop($schema);
};
}
|
[
"public",
"function",
"dropSchema",
"(",
"$",
"name",
")",
"{",
"$",
"schema",
"=",
"new",
"Schema",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"actions",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"schema",
")",
"{",
"return",
"$",
"this",
"->",
"manipulation",
"->",
"drop",
"(",
"$",
"schema",
")",
";",
"}",
";",
"}"
] |
Drop schema.
@param string $name Schema name.
@return void
|
[
"Drop",
"schema",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/MigrationApi.php#L119-L125
|
225,061
|
SetBased/php-abc-form
|
src/Validator/DateValidator.php
|
DateValidator.validate
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value===null || $value===false || $value==='') return true;
// Objects and arrays are not valid dates.
if (!is_scalar($value)) throw new LogicException('%s is not a valid date.', gettype($value));
// We assume that DateCleaner did a good job and date is in YYYY-MM-DD format.
$match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts);
$valid = ($match && checkdate($parts[2], $parts[3], $parts[1]));
if (!$valid)
{
// @todo babel
$message = sprintf("'%s' is geen geldige datum.", $control->getSubmittedValue());
$control->setErrorMessage($message);
}
return $valid;
}
|
php
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value===null || $value===false || $value==='') return true;
// Objects and arrays are not valid dates.
if (!is_scalar($value)) throw new LogicException('%s is not a valid date.', gettype($value));
// We assume that DateCleaner did a good job and date is in YYYY-MM-DD format.
$match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts);
$valid = ($match && checkdate($parts[2], $parts[3], $parts[1]));
if (!$valid)
{
// @todo babel
$message = sprintf("'%s' is geen geldige datum.", $control->getSubmittedValue());
$control->setErrorMessage($message);
}
return $valid;
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"// An empty value is valid.",
"if",
"(",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
"||",
"$",
"value",
"===",
"''",
")",
"return",
"true",
";",
"// Objects and arrays are not valid dates.",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"throw",
"new",
"LogicException",
"(",
"'%s is not a valid date.'",
",",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"// We assume that DateCleaner did a good job and date is in YYYY-MM-DD format.",
"$",
"match",
"=",
"preg_match",
"(",
"'/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/'",
",",
"$",
"value",
",",
"$",
"parts",
")",
";",
"$",
"valid",
"=",
"(",
"$",
"match",
"&&",
"checkdate",
"(",
"$",
"parts",
"[",
"2",
"]",
",",
"$",
"parts",
"[",
"3",
"]",
",",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"// @todo babel",
"$",
"message",
"=",
"sprintf",
"(",
"\"'%s' is geen geldige datum.\"",
",",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
")",
";",
"$",
"control",
"->",
"setErrorMessage",
"(",
"$",
"message",
")",
";",
"}",
"return",
"$",
"valid",
";",
"}"
] |
Returns true if the value of the form control is a valid date. Otherwise returns false.
Note:
* Empty values are considered valid.
@param Control $control The DateControl.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"value",
"of",
"the",
"form",
"control",
"is",
"a",
"valid",
"date",
".",
"Otherwise",
"returns",
"false",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/DateValidator.php#L27-L48
|
225,062
|
stubbles/stubbles-input
|
src/main/php/filter/range/StringLength.php
|
StringLength.truncate
|
public static function truncate(int $minLength = null, int $maxLength = null)
{
if (0 >= $maxLength) {
throw new \InvalidArgumentException(
'Max length must be greater than 0, otherwise truncation doesn\'t make sense'
);
}
$self = new self($minLength, $maxLength);
$self->allowsTruncate = true;
return $self;
}
|
php
|
public static function truncate(int $minLength = null, int $maxLength = null)
{
if (0 >= $maxLength) {
throw new \InvalidArgumentException(
'Max length must be greater than 0, otherwise truncation doesn\'t make sense'
);
}
$self = new self($minLength, $maxLength);
$self->allowsTruncate = true;
return $self;
}
|
[
"public",
"static",
"function",
"truncate",
"(",
"int",
"$",
"minLength",
"=",
"null",
",",
"int",
"$",
"maxLength",
"=",
"null",
")",
"{",
"if",
"(",
"0",
">=",
"$",
"maxLength",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Max length must be greater than 0, otherwise truncation doesn\\'t make sense'",
")",
";",
"}",
"$",
"self",
"=",
"new",
"self",
"(",
"$",
"minLength",
",",
"$",
"maxLength",
")",
";",
"$",
"self",
"->",
"allowsTruncate",
"=",
"true",
";",
"return",
"$",
"self",
";",
"}"
] |
create instance which treats above max border not as error, but will lead
to a truncated value only
@param int $minLength
@param int $maxLength
@return StringLength
@throws \InvalidArgumentException
@since 2.3.1
|
[
"create",
"instance",
"which",
"treats",
"above",
"max",
"border",
"not",
"as",
"error",
"but",
"will",
"lead",
"to",
"a",
"truncated",
"value",
"only"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/range/StringLength.php#L62-L73
|
225,063
|
stubbles/stubbles-input
|
src/main/php/filter/range/StringLength.php
|
StringLength.truncateToMaxBorder
|
public function truncateToMaxBorder($value)
{
if ($this->allowsTruncate($value)) {
if ($value instanceof Secret) {
return $value->substring(0, $this->maxLength);
}
return substr($value, 0, $this->maxLength);
}
throw new \LogicException('Truncate value to max length not allowed');
}
|
php
|
public function truncateToMaxBorder($value)
{
if ($this->allowsTruncate($value)) {
if ($value instanceof Secret) {
return $value->substring(0, $this->maxLength);
}
return substr($value, 0, $this->maxLength);
}
throw new \LogicException('Truncate value to max length not allowed');
}
|
[
"public",
"function",
"truncateToMaxBorder",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"allowsTruncate",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Secret",
")",
"{",
"return",
"$",
"value",
"->",
"substring",
"(",
"0",
",",
"$",
"this",
"->",
"maxLength",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"$",
"this",
"->",
"maxLength",
")",
";",
"}",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Truncate value to max length not allowed'",
")",
";",
"}"
] |
truncates given value to max length
@param string $value
@return string|Secret
@throws \LogicException
@since 2.3.1
|
[
"truncates",
"given",
"value",
"to",
"max",
"length"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/range/StringLength.php#L140-L151
|
225,064
|
SetBased/php-abc-form
|
src/Cleaner/MaxLengthCleaner.php
|
MaxLengthCleaner.clean
|
public function clean($value)
{
if ($value==='' || $value===null || $value===false)
{
return null;
}
$tmp = PruneWhitespaceCleaner::get()->clean($value);
if ($tmp==='' || $tmp===null)
{
return null;
}
return mb_substr($tmp, 0, $this->maxLength);
}
|
php
|
public function clean($value)
{
if ($value==='' || $value===null || $value===false)
{
return null;
}
$tmp = PruneWhitespaceCleaner::get()->clean($value);
if ($tmp==='' || $tmp===null)
{
return null;
}
return mb_substr($tmp, 0, $this->maxLength);
}
|
[
"public",
"function",
"clean",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"tmp",
"=",
"PruneWhitespaceCleaner",
"::",
"get",
"(",
")",
"->",
"clean",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"tmp",
"===",
"''",
"||",
"$",
"tmp",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"mb_substr",
"(",
"$",
"tmp",
",",
"0",
",",
"$",
"this",
"->",
"maxLength",
")",
";",
"}"
] |
Returns a submitted value with leading and training whitespace removed.
@param string|null $value The submitted value.
@return string|null
@since 1.0.0
@api
|
[
"Returns",
"a",
"submitted",
"value",
"with",
"leading",
"and",
"training",
"whitespace",
"removed",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Cleaner/MaxLengthCleaner.php#L44-L58
|
225,065
|
matteosister/CompassElephant
|
src/CompassElephant/CompassProject.php
|
CompassProject.compile
|
public function compile($force = false)
{
$this->commandCaller->compile($this->configFile, $force, $this->target);
}
|
php
|
public function compile($force = false)
{
$this->commandCaller->compile($this->configFile, $force, $this->target);
}
|
[
"public",
"function",
"compile",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"commandCaller",
"->",
"compile",
"(",
"$",
"this",
"->",
"configFile",
",",
"$",
"force",
",",
"$",
"this",
"->",
"target",
")",
";",
"}"
] |
Compile the project
@param bool $force
|
[
"Compile",
"the",
"project"
] |
5d2dacca5e33405872219ea5b6297e8aed964cf3
|
https://github.com/matteosister/CompassElephant/blob/5d2dacca5e33405872219ea5b6297e8aed964cf3/src/CompassElephant/CompassProject.php#L131-L134
|
225,066
|
AeonDigital/PHP-Stream
|
src/Stream.php
|
Stream.close
|
public function close() : void
{
if ($this->stream !== null) {
if ($this->isPipe === true) {
// @codeCoverageIgnoreStart
pclose($this->stream);
// @codeCoverageIgnoreEnd
} else {
fclose($this->stream);
}
}
$this->detach();
}
|
php
|
public function close() : void
{
if ($this->stream !== null) {
if ($this->isPipe === true) {
// @codeCoverageIgnoreStart
pclose($this->stream);
// @codeCoverageIgnoreEnd
} else {
fclose($this->stream);
}
}
$this->detach();
}
|
[
"public",
"function",
"close",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"stream",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPipe",
"===",
"true",
")",
"{",
"// @codeCoverageIgnoreStart",
"pclose",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"// @codeCoverageIgnoreEnd",
"}",
"else",
"{",
"fclose",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"}",
"}",
"$",
"this",
"->",
"detach",
"(",
")",
";",
"}"
] |
Encerra o "Stream".
@return void
|
[
"Encerra",
"o",
"Stream",
"."
] |
2dc446bba1d0fa1c5552f6e44e4a7d17e443cee5
|
https://github.com/AeonDigital/PHP-Stream/blob/2dc446bba1d0fa1c5552f6e44e4a7d17e443cee5/src/Stream.php#L538-L551
|
225,067
|
Innmind/Filesystem
|
src/Directory/Directory.php
|
Directory.loadDirectory
|
private function loadDirectory()
{
if ($this->generator === null) {
return;
}
foreach ($this->generator as $file) {
$this->files = $this->files->put(
(string) $file->name(),
$file
);
}
$this->generator = null;
}
|
php
|
private function loadDirectory()
{
if ($this->generator === null) {
return;
}
foreach ($this->generator as $file) {
$this->files = $this->files->put(
(string) $file->name(),
$file
);
}
$this->generator = null;
}
|
[
"private",
"function",
"loadDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"generator",
"===",
"null",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"generator",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"files",
"=",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"(",
"string",
")",
"$",
"file",
"->",
"name",
"(",
")",
",",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"generator",
"=",
"null",
";",
"}"
] |
Load all files of the directory
@return void
|
[
"Load",
"all",
"files",
"of",
"the",
"directory"
] |
21700d8424bc88e99fd5c612c5316613e4c45a3b
|
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/Directory/Directory.php#L227-L241
|
225,068
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/ClassGuesser/ModuleContextClassGuesser.php
|
ModuleContextClassGuesser.guess
|
public function guess()
{
// Try fully qualified namespace
if (class_exists($class = $this->namespaceBase.'\\'.$this->namespaceSuffix.'\\'.$this->contextClass)) {
return $class;
}
// Fall back to namespace with SilverStripe prefix
// TODO Remove once core has namespace capabilities for modules
if (class_exists($class = 'SilverStripe\\'.$this->namespaceBase.'\\'.$this->namespaceSuffix.'\\'.$this->contextClass)) {
return $class;
}
}
|
php
|
public function guess()
{
// Try fully qualified namespace
if (class_exists($class = $this->namespaceBase.'\\'.$this->namespaceSuffix.'\\'.$this->contextClass)) {
return $class;
}
// Fall back to namespace with SilverStripe prefix
// TODO Remove once core has namespace capabilities for modules
if (class_exists($class = 'SilverStripe\\'.$this->namespaceBase.'\\'.$this->namespaceSuffix.'\\'.$this->contextClass)) {
return $class;
}
}
|
[
"public",
"function",
"guess",
"(",
")",
"{",
"// Try fully qualified namespace",
"if",
"(",
"class_exists",
"(",
"$",
"class",
"=",
"$",
"this",
"->",
"namespaceBase",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"namespaceSuffix",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"contextClass",
")",
")",
"{",
"return",
"$",
"class",
";",
"}",
"// Fall back to namespace with SilverStripe prefix",
"// TODO Remove once core has namespace capabilities for modules",
"if",
"(",
"class_exists",
"(",
"$",
"class",
"=",
"'SilverStripe\\\\'",
".",
"$",
"this",
"->",
"namespaceBase",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"namespaceSuffix",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"contextClass",
")",
")",
"{",
"return",
"$",
"class",
";",
"}",
"}"
] |
Tries to guess context classname.
@return string
|
[
"Tries",
"to",
"guess",
"context",
"classname",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/ClassGuesser/ModuleContextClassGuesser.php#L44-L55
|
225,069
|
SetBased/php-abc-form
|
src/Validator/MandatoryValidator.php
|
MandatoryValidator.validate
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
if ($value==='' || $value===null || $value===false)
{
return false;
}
if (is_array($value))
{
return $this->validateArray($value);
}
return true;
}
|
php
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
if ($value==='' || $value===null || $value===false)
{
return false;
}
if (is_array($value))
{
return $this->validateArray($value);
}
return true;
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validateArray",
"(",
"$",
"value",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the form control has a value.
Note:
* Empty values are considered invalid.
* If the form control is a complex form control all child form control must have a value.
@param Control $control The form control.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"form",
"control",
"has",
"a",
"value",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/MandatoryValidator.php#L28-L43
|
225,070
|
SetBased/php-abc-form
|
src/Validator/MandatoryValidator.php
|
MandatoryValidator.validateArray
|
private function validateArray(array $array): bool
{
foreach ($array as $element)
{
if (is_array($element))
{
$tmp = $this->validateArray($element);
if ($tmp===true)
{
return true;
}
}
else
{
if ($element!==null && $element!==false && $element!=='')
{
return true;
}
}
}
return false;
}
|
php
|
private function validateArray(array $array): bool
{
foreach ($array as $element)
{
if (is_array($element))
{
$tmp = $this->validateArray($element);
if ($tmp===true)
{
return true;
}
}
else
{
if ($element!==null && $element!==false && $element!=='')
{
return true;
}
}
}
return false;
}
|
[
"private",
"function",
"validateArray",
"(",
"array",
"$",
"array",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"validateArray",
"(",
"$",
"element",
")",
";",
"if",
"(",
"$",
"tmp",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"element",
"!==",
"null",
"&&",
"$",
"element",
"!==",
"false",
"&&",
"$",
"element",
"!==",
"''",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Validates recursively if one of the leaves has a value.
@param array $array
@return bool
|
[
"Validates",
"recursively",
"if",
"one",
"of",
"the",
"leaves",
"has",
"a",
"value",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/MandatoryValidator.php#L53-L75
|
225,071
|
stubbles/stubbles-input
|
src/main/php/errors/ParamErrors.php
|
ParamErrors.append
|
public function append(string $paramName, $error, array $details = []): ParamError
{
$error = ParamError::fromData($error, $details);
if (!isset($this->errors[$paramName])) {
$this->errors[$paramName] = [$error->id() => $error];
} else {
$this->errors[$paramName][$error->id()] = $error;
}
return $error;
}
|
php
|
public function append(string $paramName, $error, array $details = []): ParamError
{
$error = ParamError::fromData($error, $details);
if (!isset($this->errors[$paramName])) {
$this->errors[$paramName] = [$error->id() => $error];
} else {
$this->errors[$paramName][$error->id()] = $error;
}
return $error;
}
|
[
"public",
"function",
"append",
"(",
"string",
"$",
"paramName",
",",
"$",
"error",
",",
"array",
"$",
"details",
"=",
"[",
"]",
")",
":",
"ParamError",
"{",
"$",
"error",
"=",
"ParamError",
"::",
"fromData",
"(",
"$",
"error",
",",
"$",
"details",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
"=",
"[",
"$",
"error",
"->",
"id",
"(",
")",
"=>",
"$",
"error",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
"[",
"$",
"error",
"->",
"id",
"(",
")",
"]",
"=",
"$",
"error",
";",
"}",
"return",
"$",
"error",
";",
"}"
] |
appends an error to the list of errors for given param name
@param string $paramName name of parameter to add error for
@param \stubbles\input\errors\ParamError|string $error id of error or an instance of ParamError
@param array $details details of what caused the error
@return \stubbles\input\errors\ParamError
@since 2.3.3
|
[
"appends",
"an",
"error",
"to",
"the",
"list",
"of",
"errors",
"for",
"given",
"param",
"name"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamErrors.php#L35-L45
|
225,072
|
stubbles/stubbles-input
|
src/main/php/errors/ParamErrors.php
|
ParamErrors.existForWithId
|
public function existForWithId(string $paramName, string $errorId): bool
{
return (isset($this->errors[$paramName]) && isset($this->errors[$paramName][$errorId]));
}
|
php
|
public function existForWithId(string $paramName, string $errorId): bool
{
return (isset($this->errors[$paramName]) && isset($this->errors[$paramName][$errorId]));
}
|
[
"public",
"function",
"existForWithId",
"(",
"string",
"$",
"paramName",
",",
"string",
"$",
"errorId",
")",
":",
"bool",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
"[",
"$",
"errorId",
"]",
")",
")",
";",
"}"
] |
checks whether a param has a specific error
@api
@param string $paramName name of parameter
@param string $errorId id of error
@return bool
|
[
"checks",
"whether",
"a",
"param",
"has",
"a",
"specific",
"error"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamErrors.php#L88-L91
|
225,073
|
stubbles/stubbles-input
|
src/main/php/errors/ParamErrors.php
|
ParamErrors.getFor
|
public function getFor(string $paramName): array
{
if (isset($this->errors[$paramName])) {
return $this->errors[$paramName];
}
return [];
}
|
php
|
public function getFor(string $paramName): array
{
if (isset($this->errors[$paramName])) {
return $this->errors[$paramName];
}
return [];
}
|
[
"public",
"function",
"getFor",
"(",
"string",
"$",
"paramName",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
returns a list of errors for given param
@param string $paramName
@return \stubbles\input\errors\ParamError[]
|
[
"returns",
"a",
"list",
"of",
"errors",
"for",
"given",
"param"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamErrors.php#L99-L106
|
225,074
|
stubbles/stubbles-input
|
src/main/php/errors/ParamErrors.php
|
ParamErrors.getForWithId
|
public function getForWithId(string $paramName, string $errorId)
{
if (isset($this->errors[$paramName]) && isset($this->errors[$paramName][$errorId])) {
return $this->errors[$paramName][$errorId];
}
return null;
}
|
php
|
public function getForWithId(string $paramName, string $errorId)
{
if (isset($this->errors[$paramName]) && isset($this->errors[$paramName][$errorId])) {
return $this->errors[$paramName][$errorId];
}
return null;
}
|
[
"public",
"function",
"getForWithId",
"(",
"string",
"$",
"paramName",
",",
"string",
"$",
"errorId",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
"[",
"$",
"errorId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"errors",
"[",
"$",
"paramName",
"]",
"[",
"$",
"errorId",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
returns the error for given param and error id
@param string $paramName name of param
@param string $errorId id of error
@return \stubbles\input\errors\ParamError|null
|
[
"returns",
"the",
"error",
"for",
"given",
"param",
"and",
"error",
"id"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamErrors.php#L115-L122
|
225,075
|
Erebot/API
|
src/Module/Base.php
|
Base.normalizeInterface
|
private static function normalizeInterface($iface)
{
if (!is_string($iface)) {
throw new \Erebot\InvalidValueException('Not an interface name');
}
$ifaceName = str_replace('!', '\\Erebot\\Interfaces\\', $iface);
if (interface_exists($ifaceName, true)) {
return strtolower($ifaceName);
}
$ifaceName = str_replace('!', '\\Erebot\\', $iface) . 'Interface';
if (interface_exists($ifaceName, true)) {
return strtolower($ifaceName);
}
throw new \Erebot\InvalidValueException('No such interface ('.$iface.')');
}
|
php
|
private static function normalizeInterface($iface)
{
if (!is_string($iface)) {
throw new \Erebot\InvalidValueException('Not an interface name');
}
$ifaceName = str_replace('!', '\\Erebot\\Interfaces\\', $iface);
if (interface_exists($ifaceName, true)) {
return strtolower($ifaceName);
}
$ifaceName = str_replace('!', '\\Erebot\\', $iface) . 'Interface';
if (interface_exists($ifaceName, true)) {
return strtolower($ifaceName);
}
throw new \Erebot\InvalidValueException('No such interface ('.$iface.')');
}
|
[
"private",
"static",
"function",
"normalizeInterface",
"(",
"$",
"iface",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"iface",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'Not an interface name'",
")",
";",
"}",
"$",
"ifaceName",
"=",
"str_replace",
"(",
"'!'",
",",
"'\\\\Erebot\\\\Interfaces\\\\'",
",",
"$",
"iface",
")",
";",
"if",
"(",
"interface_exists",
"(",
"$",
"ifaceName",
",",
"true",
")",
")",
"{",
"return",
"strtolower",
"(",
"$",
"ifaceName",
")",
";",
"}",
"$",
"ifaceName",
"=",
"str_replace",
"(",
"'!'",
",",
"'\\\\Erebot\\\\'",
",",
"$",
"iface",
")",
".",
"'Interface'",
";",
"if",
"(",
"interface_exists",
"(",
"$",
"ifaceName",
",",
"true",
")",
")",
"{",
"return",
"strtolower",
"(",
"$",
"ifaceName",
")",
";",
"}",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'No such interface ('",
".",
"$",
"iface",
".",
"')'",
")",
";",
"}"
] |
Normalize the name of a tentative interface.
\param string $iface
Name of the interface to normalize.
\retval string
Normalized name for the interface.
|
[
"Normalize",
"the",
"name",
"of",
"a",
"tentative",
"interface",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L229-L245
|
225,076
|
Erebot/API
|
src/Module/Base.php
|
Base.setFactory
|
public function setFactory($iface, $cls)
{
$ifaceName = self::normalizeInterface($iface);
if (!class_exists($cls, true)) {
throw new \Erebot\InvalidValueException('No such class ('.$cls.')');
}
$reflector = new \ReflectionClass($cls);
if (!$reflector->isSubclassOf($ifaceName)) {
throw new \Erebot\InvalidValueException(
'A class that implements the interface was expected'
);
}
$this->factories[$ifaceName] = $cls;
}
|
php
|
public function setFactory($iface, $cls)
{
$ifaceName = self::normalizeInterface($iface);
if (!class_exists($cls, true)) {
throw new \Erebot\InvalidValueException('No such class ('.$cls.')');
}
$reflector = new \ReflectionClass($cls);
if (!$reflector->isSubclassOf($ifaceName)) {
throw new \Erebot\InvalidValueException(
'A class that implements the interface was expected'
);
}
$this->factories[$ifaceName] = $cls;
}
|
[
"public",
"function",
"setFactory",
"(",
"$",
"iface",
",",
"$",
"cls",
")",
"{",
"$",
"ifaceName",
"=",
"self",
"::",
"normalizeInterface",
"(",
"$",
"iface",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"cls",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'No such class ('",
".",
"$",
"cls",
".",
"')'",
")",
";",
"}",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"cls",
")",
";",
"if",
"(",
"!",
"$",
"reflector",
"->",
"isSubclassOf",
"(",
"$",
"ifaceName",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'A class that implements the interface was expected'",
")",
";",
"}",
"$",
"this",
"->",
"factories",
"[",
"$",
"ifaceName",
"]",
"=",
"$",
"cls",
";",
"}"
] |
Set the factory for the given interface.
\param string $iface
Name of the interface to act upon.
\param string $cls
Name of the class that acts as
a factory for that interface.
If must implement that interface.
\note
As a special shortcut, an exclamation
point (!) in the interface's name will
automatically be replaced with the text
"Erebot_Interface_".
|
[
"Set",
"the",
"factory",
"for",
"the",
"given",
"interface",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L264-L279
|
225,077
|
Erebot/API
|
src/Module/Base.php
|
Base.getFactory
|
public function getFactory($iface)
{
$ifaceName = self::normalizeInterface($iface);
if (!isset($this->factories[$ifaceName])) {
throw new \Erebot\InvalidValueException('No such interface ('.$iface.')');
}
return $this->factories[$ifaceName];
}
|
php
|
public function getFactory($iface)
{
$ifaceName = self::normalizeInterface($iface);
if (!isset($this->factories[$ifaceName])) {
throw new \Erebot\InvalidValueException('No such interface ('.$iface.')');
}
return $this->factories[$ifaceName];
}
|
[
"public",
"function",
"getFactory",
"(",
"$",
"iface",
")",
"{",
"$",
"ifaceName",
"=",
"self",
"::",
"normalizeInterface",
"(",
"$",
"iface",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"factories",
"[",
"$",
"ifaceName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'No such interface ('",
".",
"$",
"iface",
".",
"')'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"factories",
"[",
"$",
"ifaceName",
"]",
";",
"}"
] |
Return the name of the class to use
to create instances with the given
interface.
\param string $iface
Name of the interface for which
the factory must be returned.
\retval string
Name of the class that acts as
a factory for that interface.
\note
As a special shortcut, an exclamation
point (!) in the interface's name will
automatically be replaced with the text
"Erebot_Interface_".
|
[
"Return",
"the",
"name",
"of",
"the",
"class",
"to",
"use",
"to",
"create",
"instances",
"with",
"the",
"given",
"interface",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L300-L307
|
225,078
|
Erebot/API
|
src/Module/Base.php
|
Base.ctcpQuote
|
protected static function ctcpQuote($message)
{
// First comes low-level quoting.
$quoting = array(
"\000" => "\0200",
"\n" => "\020n",
"\r" => "\020r",
"\020" => "\020\020",
);
$message = strtr($message, $quoting);
// Next some CTCP-level quoting and we're done.
$quoting = array(
"\001" => "\\a",
"\\" => "\\\\",
);
$message = strtr($message, $quoting);
return $message;
}
|
php
|
protected static function ctcpQuote($message)
{
// First comes low-level quoting.
$quoting = array(
"\000" => "\0200",
"\n" => "\020n",
"\r" => "\020r",
"\020" => "\020\020",
);
$message = strtr($message, $quoting);
// Next some CTCP-level quoting and we're done.
$quoting = array(
"\001" => "\\a",
"\\" => "\\\\",
);
$message = strtr($message, $quoting);
return $message;
}
|
[
"protected",
"static",
"function",
"ctcpQuote",
"(",
"$",
"message",
")",
"{",
"// First comes low-level quoting.",
"$",
"quoting",
"=",
"array",
"(",
"\"\\000\"",
"=>",
"\"\\0200\"",
",",
"\"\\n\"",
"=>",
"\"\\020n\"",
",",
"\"\\r\"",
"=>",
"\"\\020r\"",
",",
"\"\\020\"",
"=>",
"\"\\020\\020\"",
",",
")",
";",
"$",
"message",
"=",
"strtr",
"(",
"$",
"message",
",",
"$",
"quoting",
")",
";",
"// Next some CTCP-level quoting and we're done.",
"$",
"quoting",
"=",
"array",
"(",
"\"\\001\"",
"=>",
"\"\\\\a\"",
",",
"\"\\\\\"",
"=>",
"\"\\\\\\\\\"",
",",
")",
";",
"$",
"message",
"=",
"strtr",
"(",
"$",
"message",
",",
"$",
"quoting",
")",
";",
"return",
"$",
"message",
";",
"}"
] |
Quotes a CTCP message.
\param string $message
Message to quote.
\retval string
Quoted version of the message.
\see
http://www.irchelp.org/irchelp/rfc/ctcpspec.html
describes the quoting algorithm used.
|
[
"Quotes",
"a",
"CTCP",
"message",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L426-L444
|
225,079
|
Erebot/API
|
src/Module/Base.php
|
Base.sendCommand
|
protected function sendCommand($command)
{
if (!\Erebot\Utils::stringifiable($command)) {
throw new \Exception('Invalid command (not a string)');
}
$this->connection->getIO()->push((string) $command);
}
|
php
|
protected function sendCommand($command)
{
if (!\Erebot\Utils::stringifiable($command)) {
throw new \Exception('Invalid command (not a string)');
}
$this->connection->getIO()->push((string) $command);
}
|
[
"protected",
"function",
"sendCommand",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"\\",
"Erebot",
"\\",
"Utils",
"::",
"stringifiable",
"(",
"$",
"command",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid command (not a string)'",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"getIO",
"(",
")",
"->",
"push",
"(",
"(",
"string",
")",
"$",
"command",
")",
";",
"}"
] |
Send a raw command to the IRC server.
\param string $command
The command to send.
|
[
"Send",
"a",
"raw",
"command",
"to",
"the",
"IRC",
"server",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L452-L458
|
225,080
|
Erebot/API
|
src/Module/Base.php
|
Base.addTimer
|
protected function addTimer(\Erebot\TimerInterface $timer)
{
$bot = $this->connection->getBot();
return $bot->addTimer($timer);
}
|
php
|
protected function addTimer(\Erebot\TimerInterface $timer)
{
$bot = $this->connection->getBot();
return $bot->addTimer($timer);
}
|
[
"protected",
"function",
"addTimer",
"(",
"\\",
"Erebot",
"\\",
"TimerInterface",
"$",
"timer",
")",
"{",
"$",
"bot",
"=",
"$",
"this",
"->",
"connection",
"->",
"getBot",
"(",
")",
";",
"return",
"$",
"bot",
"->",
"addTimer",
"(",
"$",
"timer",
")",
";",
"}"
] |
Register a timer.
\param Erebot::TimerInterface $timer
The timer to register.
\note
This method is only a shortcut for
Erebot::Interfaces::Core::addTimer().
|
[
"Register",
"a",
"timer",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L470-L474
|
225,081
|
Erebot/API
|
src/Module/Base.php
|
Base.removeTimer
|
protected function removeTimer(\Erebot\TimerInterface $timer)
{
$bot = $this->connection->getBot();
return $bot->removeTimer($timer);
}
|
php
|
protected function removeTimer(\Erebot\TimerInterface $timer)
{
$bot = $this->connection->getBot();
return $bot->removeTimer($timer);
}
|
[
"protected",
"function",
"removeTimer",
"(",
"\\",
"Erebot",
"\\",
"TimerInterface",
"$",
"timer",
")",
"{",
"$",
"bot",
"=",
"$",
"this",
"->",
"connection",
"->",
"getBot",
"(",
")",
";",
"return",
"$",
"bot",
"->",
"removeTimer",
"(",
"$",
"timer",
")",
";",
"}"
] |
Unregister a timer.
\param Erebot::TimerInterface $timer
The timer to unregister.
\note
This method is only a shortcut for
Erebot::Interfaces::Core::removeTimer().
|
[
"Unregister",
"a",
"timer",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L486-L490
|
225,082
|
Erebot/API
|
src/Module/Base.php
|
Base.parseSomething
|
private function parseSomething($something, $param, $default)
{
$function = 'parse'.$something;
$bot = $this->connection->getBot();
if ($this->channel !== null) {
try {
$config = $this->connection->getConfig($this->channel);
return $config->$function('\\' . get_called_class(), $param);
} catch (\Erebot\Exception $e) {
unset($config);
}
}
$config = $this->connection->getConfig(null);
return $config->$function('\\' . get_called_class(), $param, $default);
}
|
php
|
private function parseSomething($something, $param, $default)
{
$function = 'parse'.$something;
$bot = $this->connection->getBot();
if ($this->channel !== null) {
try {
$config = $this->connection->getConfig($this->channel);
return $config->$function('\\' . get_called_class(), $param);
} catch (\Erebot\Exception $e) {
unset($config);
}
}
$config = $this->connection->getConfig(null);
return $config->$function('\\' . get_called_class(), $param, $default);
}
|
[
"private",
"function",
"parseSomething",
"(",
"$",
"something",
",",
"$",
"param",
",",
"$",
"default",
")",
"{",
"$",
"function",
"=",
"'parse'",
".",
"$",
"something",
";",
"$",
"bot",
"=",
"$",
"this",
"->",
"connection",
"->",
"getBot",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"channel",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"return",
"$",
"config",
"->",
"$",
"function",
"(",
"'\\\\'",
".",
"get_called_class",
"(",
")",
",",
"$",
"param",
")",
";",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"Exception",
"$",
"e",
")",
"{",
"unset",
"(",
"$",
"config",
")",
";",
"}",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
"null",
")",
";",
"return",
"$",
"config",
"->",
"$",
"function",
"(",
"'\\\\'",
".",
"get_called_class",
"(",
")",
",",
"$",
"param",
",",
"$",
"default",
")",
";",
"}"
] |
\internal
Retrieves a parameter from the module's configuration
by recursively traversing the configuration hierarchy
and parses it using the appropriate function.
\param string $something
The type of parsing to apply to the parameter.
This is used to determine the correct parsing
method to call.
\param string $param
The name of the parameter to retrieve.
\param mixed $default
The default value if the parameter is absent.
It's actual type depends on the type of parsing
applied by the $something argument.
\warning
This method may throw several exceptions for
different reasons (such as a missing parameter,
an invalid value or an invalid default value).
|
[
"\\",
"internal",
"Retrieves",
"a",
"parameter",
"from",
"the",
"module",
"s",
"configuration",
"by",
"recursively",
"traversing",
"the",
"configuration",
"hierarchy",
"and",
"parses",
"it",
"using",
"the",
"appropriate",
"function",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L516-L530
|
225,083
|
Erebot/API
|
src/Module/Base.php
|
Base.getFormatter
|
protected function getFormatter($chan)
{
$cls = $this->getFactory('!Styling');
if ($chan === false) {
return new $cls($this->translator);
} elseif ($chan !== null) {
$config = $this->connection->getConfig($chan);
try {
return new $cls($config->getTranslator(get_called_class()));
} catch (\Erebot\Exception $e) {
// The channel lacked a specific config. Use the cascade.
}
unset($config);
}
$config = $this->connection->getConfig($this->channel);
try {
return new $cls($config->getTranslator(get_called_class()));
} catch (\Erebot\Exception $e) {
// The channel lacked a specific config. Use the cascade.
}
unset($config);
$config = $this->connection->getConfig(null);
return new $cls($config->getTranslator(get_called_class()));
}
|
php
|
protected function getFormatter($chan)
{
$cls = $this->getFactory('!Styling');
if ($chan === false) {
return new $cls($this->translator);
} elseif ($chan !== null) {
$config = $this->connection->getConfig($chan);
try {
return new $cls($config->getTranslator(get_called_class()));
} catch (\Erebot\Exception $e) {
// The channel lacked a specific config. Use the cascade.
}
unset($config);
}
$config = $this->connection->getConfig($this->channel);
try {
return new $cls($config->getTranslator(get_called_class()));
} catch (\Erebot\Exception $e) {
// The channel lacked a specific config. Use the cascade.
}
unset($config);
$config = $this->connection->getConfig(null);
return new $cls($config->getTranslator(get_called_class()));
}
|
[
"protected",
"function",
"getFormatter",
"(",
"$",
"chan",
")",
"{",
"$",
"cls",
"=",
"$",
"this",
"->",
"getFactory",
"(",
"'!Styling'",
")",
";",
"if",
"(",
"$",
"chan",
"===",
"false",
")",
"{",
"return",
"new",
"$",
"cls",
"(",
"$",
"this",
"->",
"translator",
")",
";",
"}",
"elseif",
"(",
"$",
"chan",
"!==",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
"$",
"chan",
")",
";",
"try",
"{",
"return",
"new",
"$",
"cls",
"(",
"$",
"config",
"->",
"getTranslator",
"(",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// The channel lacked a specific config. Use the cascade.",
"}",
"unset",
"(",
"$",
"config",
")",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"try",
"{",
"return",
"new",
"$",
"cls",
"(",
"$",
"config",
"->",
"getTranslator",
"(",
"get_called_class",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// The channel lacked a specific config. Use the cascade.",
"}",
"unset",
"(",
"$",
"config",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
"null",
")",
";",
"return",
"new",
"$",
"cls",
"(",
"$",
"config",
"->",
"getTranslator",
"(",
"get_called_class",
"(",
")",
")",
")",
";",
"}"
] |
Returns the appropriate formatter for the given channel.
\param null|false|string $chan
The channel for which a formatter must be returned.
If $chan is \b null, the hierarchy of configurations
is traversed to find the most appropriate formatter.
If $chan is \b false, a formatter is built using the
bot's main translator.
\retval Erebot::StylingInterface
A formatter for the given channel.
|
[
"Returns",
"the",
"appropriate",
"formatter",
"for",
"the",
"given",
"channel",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Module/Base.php#L665-L690
|
225,084
|
SetBased/php-abc-form
|
src/Control/DateControl.php
|
DateControl.setOpenDate
|
public function setOpenDate(string $openDate): void
{
$this->cleaner->setOpenDate($openDate);
$this->formatter->setOpenDate($openDate);
}
|
php
|
public function setOpenDate(string $openDate): void
{
$this->cleaner->setOpenDate($openDate);
$this->formatter->setOpenDate($openDate);
}
|
[
"public",
"function",
"setOpenDate",
"(",
"string",
"$",
"openDate",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cleaner",
"->",
"setOpenDate",
"(",
"$",
"openDate",
")",
";",
"$",
"this",
"->",
"formatter",
"->",
"setOpenDate",
"(",
"$",
"openDate",
")",
";",
"}"
] |
Sets the open date. An empty submitted value will be replaced with the open date and an open date will be shown as
an empty field.
@param string $openDate The open date in YYYY-MM-DD format.
@since 1.0.0
@api
|
[
"Sets",
"the",
"open",
"date",
".",
"An",
"empty",
"submitted",
"value",
"will",
"be",
"replaced",
"with",
"the",
"open",
"date",
"and",
"an",
"open",
"date",
"will",
"be",
"shown",
"as",
"an",
"empty",
"field",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/DateControl.php#L60-L64
|
225,085
|
spiral/translator
|
src/Catalogue/CatalogueManager.php
|
CatalogueManager.reset
|
public function reset()
{
$this->cache->setLocales(null);
foreach ($this->getLocales() as $locale) {
$this->cache->saveLocale($locale, null);
}
$this->locales = [];
$this->catalogues = [];
}
|
php
|
public function reset()
{
$this->cache->setLocales(null);
foreach ($this->getLocales() as $locale) {
$this->cache->saveLocale($locale, null);
}
$this->locales = [];
$this->catalogues = [];
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"setLocales",
"(",
"null",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"saveLocale",
"(",
"$",
"locale",
",",
"null",
")",
";",
"}",
"$",
"this",
"->",
"locales",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"catalogues",
"=",
"[",
"]",
";",
"}"
] |
Reset all cached data and loaded locates.
|
[
"Reset",
"all",
"cached",
"data",
"and",
"loaded",
"locates",
"."
] |
dde0f3d3db7960c22a36b9e781fe30ab51656424
|
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Catalogue/CatalogueManager.php#L116-L125
|
225,086
|
RevisionTen/cqrs
|
Services/EventBus.php
|
EventBus.publish
|
public function publish(array $events, CommandBus $commandBus, bool $qeueEvents = false): void
{
$eventStreamObjects = [];
/**
* @var EventInterface $event
*/
foreach ($events as $event) {
// Save the event to the event stream.
$eventStreamObject = new EventStreamObject();
$eventStreamObject->setUuid($event->getCommand()->getAggregateUuid());
$eventStreamObject->setCommandUuid($event->getCommand()->getUuid());
$eventStreamObject->setPayload($event->getCommand()->getPayload());
$eventStreamObject->setMessage($event->getMessage());
$eventStreamObject->setEvent(\get_class($event));
$eventStreamObject->setAggregateClass($event->getCommand()->getAggregateClass());
$eventStreamObject->setVersion($event->getCommand()->getOnVersion() + 1);
$eventStreamObject->setUser($event->getCommand()->getUser());
// Add to list of eventStreamObjects so we can later notify aggregateSubscribers.
$eventStreamObjects[] = $eventStreamObject;
// Add the events to the eventStore.
if ($qeueEvents) {
$eventQeueObject = new EventQeueObject($eventStreamObject);
$this->eventStore->qeue($eventQeueObject);
$message = 'Qeued event: '.$event->getMessage();
} else {
$this->eventStore->add($eventStreamObject);
$message = 'Persisted event: '.$event->getMessage();
}
// Dispatch messages about the events.
$this->messageBus->dispatch(new Message(
$message,
$event::getCode(),
$event->getCommand()->getUuid(),
$event->getCommand()->getAggregateUuid(),
null,
$event->getCommand()->getPayload()
));
}
try {
$this->eventStore->save();
// Listeners are called even if the events are just qeued!
// They are not called again when the events are persisted to the event stream!
$this->invokeListeners($events, $commandBus);
// Notify subscribers.
// Subscribers are notified AFTER the events listeners are processed.
// Subscribers are NOT notified of qeued events.
if (!$qeueEvents) {
$this->sendAggregateUpdates($eventStreamObjects);
}
} catch (\Exception $e) {
// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
}
}
|
php
|
public function publish(array $events, CommandBus $commandBus, bool $qeueEvents = false): void
{
$eventStreamObjects = [];
/**
* @var EventInterface $event
*/
foreach ($events as $event) {
// Save the event to the event stream.
$eventStreamObject = new EventStreamObject();
$eventStreamObject->setUuid($event->getCommand()->getAggregateUuid());
$eventStreamObject->setCommandUuid($event->getCommand()->getUuid());
$eventStreamObject->setPayload($event->getCommand()->getPayload());
$eventStreamObject->setMessage($event->getMessage());
$eventStreamObject->setEvent(\get_class($event));
$eventStreamObject->setAggregateClass($event->getCommand()->getAggregateClass());
$eventStreamObject->setVersion($event->getCommand()->getOnVersion() + 1);
$eventStreamObject->setUser($event->getCommand()->getUser());
// Add to list of eventStreamObjects so we can later notify aggregateSubscribers.
$eventStreamObjects[] = $eventStreamObject;
// Add the events to the eventStore.
if ($qeueEvents) {
$eventQeueObject = new EventQeueObject($eventStreamObject);
$this->eventStore->qeue($eventQeueObject);
$message = 'Qeued event: '.$event->getMessage();
} else {
$this->eventStore->add($eventStreamObject);
$message = 'Persisted event: '.$event->getMessage();
}
// Dispatch messages about the events.
$this->messageBus->dispatch(new Message(
$message,
$event::getCode(),
$event->getCommand()->getUuid(),
$event->getCommand()->getAggregateUuid(),
null,
$event->getCommand()->getPayload()
));
}
try {
$this->eventStore->save();
// Listeners are called even if the events are just qeued!
// They are not called again when the events are persisted to the event stream!
$this->invokeListeners($events, $commandBus);
// Notify subscribers.
// Subscribers are notified AFTER the events listeners are processed.
// Subscribers are NOT notified of qeued events.
if (!$qeueEvents) {
$this->sendAggregateUpdates($eventStreamObjects);
}
} catch (\Exception $e) {
// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
}
}
|
[
"public",
"function",
"publish",
"(",
"array",
"$",
"events",
",",
"CommandBus",
"$",
"commandBus",
",",
"bool",
"$",
"qeueEvents",
"=",
"false",
")",
":",
"void",
"{",
"$",
"eventStreamObjects",
"=",
"[",
"]",
";",
"/**\n * @var EventInterface $event\n */",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"// Save the event to the event stream.",
"$",
"eventStreamObject",
"=",
"new",
"EventStreamObject",
"(",
")",
";",
"$",
"eventStreamObject",
"->",
"setUuid",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getAggregateUuid",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setCommandUuid",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getUuid",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setPayload",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getPayload",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setMessage",
"(",
"$",
"event",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setEvent",
"(",
"\\",
"get_class",
"(",
"$",
"event",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setAggregateClass",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getAggregateClass",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setVersion",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getOnVersion",
"(",
")",
"+",
"1",
")",
";",
"$",
"eventStreamObject",
"->",
"setUser",
"(",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getUser",
"(",
")",
")",
";",
"// Add to list of eventStreamObjects so we can later notify aggregateSubscribers.",
"$",
"eventStreamObjects",
"[",
"]",
"=",
"$",
"eventStreamObject",
";",
"// Add the events to the eventStore.",
"if",
"(",
"$",
"qeueEvents",
")",
"{",
"$",
"eventQeueObject",
"=",
"new",
"EventQeueObject",
"(",
"$",
"eventStreamObject",
")",
";",
"$",
"this",
"->",
"eventStore",
"->",
"qeue",
"(",
"$",
"eventQeueObject",
")",
";",
"$",
"message",
"=",
"'Qeued event: '",
".",
"$",
"event",
"->",
"getMessage",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"add",
"(",
"$",
"eventStreamObject",
")",
";",
"$",
"message",
"=",
"'Persisted event: '",
".",
"$",
"event",
"->",
"getMessage",
"(",
")",
";",
"}",
"// Dispatch messages about the events.",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"message",
",",
"$",
"event",
"::",
"getCode",
"(",
")",
",",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getUuid",
"(",
")",
",",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getAggregateUuid",
"(",
")",
",",
"null",
",",
"$",
"event",
"->",
"getCommand",
"(",
")",
"->",
"getPayload",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"save",
"(",
")",
";",
"// Listeners are called even if the events are just qeued!",
"// They are not called again when the events are persisted to the event stream!",
"$",
"this",
"->",
"invokeListeners",
"(",
"$",
"events",
",",
"$",
"commandBus",
")",
";",
"// Notify subscribers.",
"// Subscribers are notified AFTER the events listeners are processed.",
"// Subscribers are NOT notified of qeued events.",
"if",
"(",
"!",
"$",
"qeueEvents",
")",
"{",
"$",
"this",
"->",
"sendAggregateUpdates",
"(",
"$",
"eventStreamObjects",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"null",
",",
"$",
"e",
")",
")",
";",
"}",
"}"
] |
Dispatch all events to observing event handlers and save them to the Event Store.
@param array $events
@param CommandBus $commandBus
@param bool $qeueEvents
|
[
"Dispatch",
"all",
"events",
"to",
"observing",
"event",
"handlers",
"and",
"save",
"them",
"to",
"the",
"Event",
"Store",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventBus.php#L63-L128
|
225,087
|
RevisionTen/cqrs
|
Services/EventBus.php
|
EventBus.publishQeued
|
public function publishQeued(array $eventQeueObjects): bool
{
$eventStreamObjects = array_map(function ($eventQeueObject) {
/* @var EventQeueObject $eventQeueObject */
return $eventQeueObject->getEventStreamObject();
}, $eventQeueObjects);
/**
* Add EventStreamObjects to list of EventStreamObjects that should be persisted.
*
* @var EventStreamObject $eventStreamObject
*/
foreach ($eventStreamObjects as $eventStreamObject) {
$this->eventStore->add($eventStreamObject);
}
try {
$this->eventStore->save();
// Notify subscribers.
$this->sendAggregateUpdates($eventStreamObjects);
} catch (\Exception $e) {
// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
return false;
}
/**
* Remove EventQeueObjects from qeue.
*
* @var EventQeueObject $eventQeueObject
*/
foreach ($eventQeueObjects as $eventQeueObject) {
$this->eventStore->remove($eventQeueObject);
}
try {
$this->eventStore->save();
return true;
} catch (\Exception $e) {
// Removal from the Event Qeue failed.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
return false;
}
}
|
php
|
public function publishQeued(array $eventQeueObjects): bool
{
$eventStreamObjects = array_map(function ($eventQeueObject) {
/* @var EventQeueObject $eventQeueObject */
return $eventQeueObject->getEventStreamObject();
}, $eventQeueObjects);
/**
* Add EventStreamObjects to list of EventStreamObjects that should be persisted.
*
* @var EventStreamObject $eventStreamObject
*/
foreach ($eventStreamObjects as $eventStreamObject) {
$this->eventStore->add($eventStreamObject);
}
try {
$this->eventStore->save();
// Notify subscribers.
$this->sendAggregateUpdates($eventStreamObjects);
} catch (\Exception $e) {
// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
return false;
}
/**
* Remove EventQeueObjects from qeue.
*
* @var EventQeueObject $eventQeueObject
*/
foreach ($eventQeueObjects as $eventQeueObject) {
$this->eventStore->remove($eventQeueObject);
}
try {
$this->eventStore->save();
return true;
} catch (\Exception $e) {
// Removal from the Event Qeue failed.
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
return false;
}
}
|
[
"public",
"function",
"publishQeued",
"(",
"array",
"$",
"eventQeueObjects",
")",
":",
"bool",
"{",
"$",
"eventStreamObjects",
"=",
"array_map",
"(",
"function",
"(",
"$",
"eventQeueObject",
")",
"{",
"/* @var EventQeueObject $eventQeueObject */",
"return",
"$",
"eventQeueObject",
"->",
"getEventStreamObject",
"(",
")",
";",
"}",
",",
"$",
"eventQeueObjects",
")",
";",
"/**\n * Add EventStreamObjects to list of EventStreamObjects that should be persisted.\n *\n * @var EventStreamObject $eventStreamObject\n */",
"foreach",
"(",
"$",
"eventStreamObjects",
"as",
"$",
"eventStreamObject",
")",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"add",
"(",
"$",
"eventStreamObject",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"save",
"(",
")",
";",
"// Notify subscribers.",
"$",
"this",
"->",
"sendAggregateUpdates",
"(",
"$",
"eventStreamObjects",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"null",
",",
"$",
"e",
")",
")",
";",
"return",
"false",
";",
"}",
"/**\n * Remove EventQeueObjects from qeue.\n *\n * @var EventQeueObject $eventQeueObject\n */",
"foreach",
"(",
"$",
"eventQeueObjects",
"as",
"$",
"eventQeueObject",
")",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"remove",
"(",
"$",
"eventQeueObject",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"eventStore",
"->",
"save",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Removal from the Event Qeue failed.",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"null",
",",
"$",
"e",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Save qeued Events to the Event Stream.
@param EventQeueObject[] $eventQeueObjects
@return bool
|
[
"Save",
"qeued",
"Events",
"to",
"the",
"Event",
"Stream",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventBus.php#L137-L196
|
225,088
|
SetBased/php-abc-http-header
|
src/HttpHeader.php
|
HttpHeader.clearOutput
|
public static function clearOutput(): void
{
// Return immediately if skipClearOutput is set.
if (self::$skipClearOutput) return;
$level = ob_get_level();
// The following manual level counting is to deal with zlib.output_compression set to On.
for ($i = $level; $i>0; --$i)
{
if (!@ob_end_clean())
{
ob_clean();
}
}
if ($level>0)
{
// Restart output buffer in order to allow modification of headers.
ob_start();
}
}
|
php
|
public static function clearOutput(): void
{
// Return immediately if skipClearOutput is set.
if (self::$skipClearOutput) return;
$level = ob_get_level();
// The following manual level counting is to deal with zlib.output_compression set to On.
for ($i = $level; $i>0; --$i)
{
if (!@ob_end_clean())
{
ob_clean();
}
}
if ($level>0)
{
// Restart output buffer in order to allow modification of headers.
ob_start();
}
}
|
[
"public",
"static",
"function",
"clearOutput",
"(",
")",
":",
"void",
"{",
"// Return immediately if skipClearOutput is set.",
"if",
"(",
"self",
"::",
"$",
"skipClearOutput",
")",
"return",
";",
"$",
"level",
"=",
"ob_get_level",
"(",
")",
";",
"// The following manual level counting is to deal with zlib.output_compression set to On.",
"for",
"(",
"$",
"i",
"=",
"$",
"level",
";",
"$",
"i",
">",
"0",
";",
"--",
"$",
"i",
")",
"{",
"if",
"(",
"!",
"@",
"ob_end_clean",
"(",
")",
")",
"{",
"ob_clean",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"level",
">",
"0",
")",
"{",
"// Restart output buffer in order to allow modification of headers.",
"ob_start",
"(",
")",
";",
"}",
"}"
] |
Removes all output echoed before calling this method.
@since 1.0.0
@api
|
[
"Removes",
"all",
"output",
"echoed",
"before",
"calling",
"this",
"method",
"."
] |
da56077a27c7e06ea2c8301f7722610f814bc340
|
https://github.com/SetBased/php-abc-http-header/blob/da56077a27c7e06ea2c8301f7722610f814bc340/src/HttpHeader.php#L151-L172
|
225,089
|
SetBased/php-abc-http-header
|
src/HttpHeader.php
|
HttpHeader.error
|
private static function error(int $statusCode): void
{
self::clearOutput();
self::$status = $statusCode;
header('HTTP/1.1 '.$statusCode.' '.self::$httpStatuses[$statusCode]);
}
|
php
|
private static function error(int $statusCode): void
{
self::clearOutput();
self::$status = $statusCode;
header('HTTP/1.1 '.$statusCode.' '.self::$httpStatuses[$statusCode]);
}
|
[
"private",
"static",
"function",
"error",
"(",
"int",
"$",
"statusCode",
")",
":",
"void",
"{",
"self",
"::",
"clearOutput",
"(",
")",
";",
"self",
"::",
"$",
"status",
"=",
"$",
"statusCode",
";",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"statusCode",
".",
"' '",
".",
"self",
"::",
"$",
"httpStatuses",
"[",
"$",
"statusCode",
"]",
")",
";",
"}"
] |
Sets the status code for the HTTP request to a client or server error.
The output buffer will be erased, see [ob_clean](http://php.net/manual/function.ob-clean.php).
@param int $statusCode The HTTP status code, must be a 4xx (client error) or 5xx (server error) status code. See
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html> for details about HTTP status
codes.
|
[
"Sets",
"the",
"status",
"code",
"for",
"the",
"HTTP",
"request",
"to",
"a",
"client",
"or",
"server",
"error",
"."
] |
da56077a27c7e06ea2c8301f7722610f814bc340
|
https://github.com/SetBased/php-abc-http-header/blob/da56077a27c7e06ea2c8301f7722610f814bc340/src/HttpHeader.php#L268-L274
|
225,090
|
SetBased/php-abc-http-header
|
src/HttpHeader.php
|
HttpHeader.redirect
|
private static function redirect(string $url, bool $forceRelative, int $statusCode): void
{
if ($forceRelative && !Url::isRelative($url))
{
$url = '/';
}
self::clearOutput();
self::$status = $statusCode;
header('HTTP/1.1 '.$statusCode.' '.self::$httpStatuses[$statusCode]);
header('location: '.$url);
}
|
php
|
private static function redirect(string $url, bool $forceRelative, int $statusCode): void
{
if ($forceRelative && !Url::isRelative($url))
{
$url = '/';
}
self::clearOutput();
self::$status = $statusCode;
header('HTTP/1.1 '.$statusCode.' '.self::$httpStatuses[$statusCode]);
header('location: '.$url);
}
|
[
"private",
"static",
"function",
"redirect",
"(",
"string",
"$",
"url",
",",
"bool",
"$",
"forceRelative",
",",
"int",
"$",
"statusCode",
")",
":",
"void",
"{",
"if",
"(",
"$",
"forceRelative",
"&&",
"!",
"Url",
"::",
"isRelative",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"'/'",
";",
"}",
"self",
"::",
"clearOutput",
"(",
")",
";",
"self",
"::",
"$",
"status",
"=",
"$",
"statusCode",
";",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"statusCode",
".",
"' '",
".",
"self",
"::",
"$",
"httpStatuses",
"[",
"$",
"statusCode",
"]",
")",
";",
"header",
"(",
"'location: '",
".",
"$",
"url",
")",
";",
"}"
] |
Redirects the user agent to a specified URL.
The output buffer will be erased, see [ob_clean](http://php.net/manual/function.ob-clean.php).
This method will protect against unvalidated redirects, see
<https://www.owasp.org/index.php/Unvalidated_Redirects_and_Forwards_Cheat_Sheet>.
@param string $url The URL to redirect the user agent.
@param bool $forceRelative If set the URL will be validated to be a relative URL, if not so the URL will
be replaced with '/'.
@param int $statusCode The HTTP status code. See
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html> for details about HTTP
status codes.
|
[
"Redirects",
"the",
"user",
"agent",
"to",
"a",
"specified",
"URL",
"."
] |
da56077a27c7e06ea2c8301f7722610f814bc340
|
https://github.com/SetBased/php-abc-http-header/blob/da56077a27c7e06ea2c8301f7722610f814bc340/src/HttpHeader.php#L292-L304
|
225,091
|
bytic/Common
|
src/Records/Media/Files/Model.php
|
Model.upload
|
public function upload($uploadedFile)
{
if ($uploadedFile->isValid()) {
$this->getFilesystem()->putFileAs(
dirname($this->getPath()),
$uploadedFile,
$this->getName()
);
return true;
} else {
$this->errors['upload'] = $uploadedFile->getErrorMessage();
}
return false;
}
|
php
|
public function upload($uploadedFile)
{
if ($uploadedFile->isValid()) {
$this->getFilesystem()->putFileAs(
dirname($this->getPath()),
$uploadedFile,
$this->getName()
);
return true;
} else {
$this->errors['upload'] = $uploadedFile->getErrorMessage();
}
return false;
}
|
[
"public",
"function",
"upload",
"(",
"$",
"uploadedFile",
")",
"{",
"if",
"(",
"$",
"uploadedFile",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
"->",
"putFileAs",
"(",
"dirname",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
",",
"$",
"uploadedFile",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errors",
"[",
"'upload'",
"]",
"=",
"$",
"uploadedFile",
"->",
"getErrorMessage",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Upload file from http
@param UploadedFile $uploadedFile
@return bool
|
[
"Upload",
"file",
"from",
"http"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Media/Files/Model.php#L45-L60
|
225,092
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configuration/adapter/AdapterXML.php
|
AdapterXML.loadXML
|
private function loadXML($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
}
libxml_clear_errors();
$oldValue = libxml_use_internal_errors(true);
// Load XML
$xml = @simplexml_load_file($url);
if ($xml === false) {
$errorStr = "";
foreach(libxml_get_errors() as $error) {
$errorStr .= "[" . $error->file . "] line " . $error->line . " : " . $error->message;
}
throw new \n2n\log4php\LoggerException("Error loading configuration file: " . trim($errorStr));
}
libxml_clear_errors();
libxml_use_internal_errors($oldValue);
return $xml;
}
|
php
|
private function loadXML($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File [$url] does not exist.");
}
libxml_clear_errors();
$oldValue = libxml_use_internal_errors(true);
// Load XML
$xml = @simplexml_load_file($url);
if ($xml === false) {
$errorStr = "";
foreach(libxml_get_errors() as $error) {
$errorStr .= "[" . $error->file . "] line " . $error->line . " : " . $error->message;
}
throw new \n2n\log4php\LoggerException("Error loading configuration file: " . trim($errorStr));
}
libxml_clear_errors();
libxml_use_internal_errors($oldValue);
return $xml;
}
|
[
"private",
"function",
"loadXML",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"File [$url] does not exist.\"",
")",
";",
"}",
"libxml_clear_errors",
"(",
")",
";",
"$",
"oldValue",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"// Load XML\r",
"$",
"xml",
"=",
"@",
"simplexml_load_file",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"xml",
"===",
"false",
")",
"{",
"$",
"errorStr",
"=",
"\"\"",
";",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"errorStr",
".=",
"\"[\"",
".",
"$",
"error",
"->",
"file",
".",
"\"] line \"",
".",
"$",
"error",
"->",
"line",
".",
"\" : \"",
".",
"$",
"error",
"->",
"message",
";",
"}",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"Error loading configuration file: \"",
".",
"trim",
"(",
"$",
"errorStr",
")",
")",
";",
"}",
"libxml_clear_errors",
"(",
")",
";",
"libxml_use_internal_errors",
"(",
"$",
"oldValue",
")",
";",
"return",
"$",
"xml",
";",
"}"
] |
Loads and validates the XML.
@param string $url Input XML.
|
[
"Loads",
"and",
"validates",
"the",
"XML",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configuration/adapter/AdapterXML.php#L79-L103
|
225,093
|
WyriHaximus/reactphp-inspector-event-loop
|
src/LoopDecorator.php
|
LoopDecorator.removeReadStream
|
public function removeReadStream($stream)
{
$key = (int) $stream;
if (isset($this->streamsRead[$key])) {
unset($this->streamsRead[$key]);
}
if (isset($this->streamsDuplex[$key]) && !isset($this->streamsWrite[$key])) {
unset($this->streamsDuplex[$key]);
}
GlobalState::set('eventloop.streams.read.current', count($this->streamsRead));
GlobalState::set('eventloop.streams.total.current', count($this->streamsDuplex));
$this->loop->removeReadStream($stream);
}
|
php
|
public function removeReadStream($stream)
{
$key = (int) $stream;
if (isset($this->streamsRead[$key])) {
unset($this->streamsRead[$key]);
}
if (isset($this->streamsDuplex[$key]) && !isset($this->streamsWrite[$key])) {
unset($this->streamsDuplex[$key]);
}
GlobalState::set('eventloop.streams.read.current', count($this->streamsRead));
GlobalState::set('eventloop.streams.total.current', count($this->streamsDuplex));
$this->loop->removeReadStream($stream);
}
|
[
"public",
"function",
"removeReadStream",
"(",
"$",
"stream",
")",
"{",
"$",
"key",
"=",
"(",
"int",
")",
"$",
"stream",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"streamsRead",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"streamsRead",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"streamsDuplex",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"streamsWrite",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"streamsDuplex",
"[",
"$",
"key",
"]",
")",
";",
"}",
"GlobalState",
"::",
"set",
"(",
"'eventloop.streams.read.current'",
",",
"count",
"(",
"$",
"this",
"->",
"streamsRead",
")",
")",
";",
"GlobalState",
"::",
"set",
"(",
"'eventloop.streams.total.current'",
",",
"count",
"(",
"$",
"this",
"->",
"streamsDuplex",
")",
")",
";",
"$",
"this",
"->",
"loop",
"->",
"removeReadStream",
"(",
"$",
"stream",
")",
";",
"}"
] |
Remove the read event listener for the given stream.
@param stream $stream The PHP stream resource.
|
[
"Remove",
"the",
"read",
"event",
"listener",
"for",
"the",
"given",
"stream",
"."
] |
e826a11ef787e71af68f0da0e660f8a07c0f49d5
|
https://github.com/WyriHaximus/reactphp-inspector-event-loop/blob/e826a11ef787e71af68f0da0e660f8a07c0f49d5/src/LoopDecorator.php#L116-L131
|
225,094
|
cmsgears/module-cart
|
common/models/resources/OrderItem.php
|
OrderItem.findByParentCartId
|
public static function findByParentCartId( $parentId, $parentType, $orderId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND orderId=:oid', [ ':pid' => $parentId, ':ptype' => $parentType, ':oid' => $orderId ] )->one();
}
|
php
|
public static function findByParentCartId( $parentId, $parentType, $orderId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND orderId=:oid', [ ':pid' => $parentId, ':ptype' => $parentType, ':oid' => $orderId ] )->one();
}
|
[
"public",
"static",
"function",
"findByParentCartId",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"orderId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'parentId=:pid AND parentType=:ptype AND orderId=:oid'",
",",
"[",
"':pid'",
"=>",
"$",
"parentId",
",",
"':ptype'",
"=>",
"$",
"parentType",
",",
"':oid'",
"=>",
"$",
"orderId",
"]",
")",
"->",
"one",
"(",
")",
";",
"}"
] |
Return the order item associated with given parent id, parent type and order id.
@param integer $parentId
@param string $parentType
@param integer $orderId
@return OrderItem
|
[
"Return",
"the",
"order",
"item",
"associated",
"with",
"given",
"parent",
"id",
"parent",
"type",
"and",
"order",
"id",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/OrderItem.php#L363-L366
|
225,095
|
korchasa/telegram-php
|
src/Unstructured.php
|
Unstructured.get
|
protected function get($object_or_array, $key, $default = null)
{
if (is_array($object_or_array)) {
if (is_null($key)) {
return $object_or_array;
}
if (isset($object_or_array[$key])) {
return $object_or_array[$key];
}
foreach (explode('.', $key) as $segment) {
if (!is_array($object_or_array) || !array_key_exists($segment, $object_or_array)) {
return value($default);
}
$object_or_array = $object_or_array[$segment];
}
return $object_or_array;
} else {
if (is_null($key) || trim($key) == '') {
return $object_or_array;
}
foreach (explode('.', $key) as $segment) {
if (!is_object($object_or_array) || !isset($object_or_array->{$segment})) {
return value($default);
}
$object_or_array = $object_or_array->{$segment};
}
return $object_or_array;
}
}
|
php
|
protected function get($object_or_array, $key, $default = null)
{
if (is_array($object_or_array)) {
if (is_null($key)) {
return $object_or_array;
}
if (isset($object_or_array[$key])) {
return $object_or_array[$key];
}
foreach (explode('.', $key) as $segment) {
if (!is_array($object_or_array) || !array_key_exists($segment, $object_or_array)) {
return value($default);
}
$object_or_array = $object_or_array[$segment];
}
return $object_or_array;
} else {
if (is_null($key) || trim($key) == '') {
return $object_or_array;
}
foreach (explode('.', $key) as $segment) {
if (!is_object($object_or_array) || !isset($object_or_array->{$segment})) {
return value($default);
}
$object_or_array = $object_or_array->{$segment};
}
return $object_or_array;
}
}
|
[
"protected",
"function",
"get",
"(",
"$",
"object_or_array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object_or_array",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"object_or_array",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object_or_array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"object_or_array",
"[",
"$",
"key",
"]",
";",
"}",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"object_or_array",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"object_or_array",
")",
")",
"{",
"return",
"value",
"(",
"$",
"default",
")",
";",
"}",
"$",
"object_or_array",
"=",
"$",
"object_or_array",
"[",
"$",
"segment",
"]",
";",
"}",
"return",
"$",
"object_or_array",
";",
"}",
"else",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
"||",
"trim",
"(",
"$",
"key",
")",
"==",
"''",
")",
"{",
"return",
"$",
"object_or_array",
";",
"}",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object_or_array",
")",
"||",
"!",
"isset",
"(",
"$",
"object_or_array",
"->",
"{",
"$",
"segment",
"}",
")",
")",
"{",
"return",
"value",
"(",
"$",
"default",
")",
";",
"}",
"$",
"object_or_array",
"=",
"$",
"object_or_array",
"->",
"{",
"$",
"segment",
"}",
";",
"}",
"return",
"$",
"object_or_array",
";",
"}",
"}"
] |
Get an item from an object or array using "dot" notation.
@param object|array $object_or_array
@param string $key
@param mixed $default
@return mixed
|
[
"Get",
"an",
"item",
"from",
"an",
"object",
"or",
"array",
"using",
"dot",
"notation",
"."
] |
96df8089c4a68a35a7e82da79f087e6c2ca92316
|
https://github.com/korchasa/telegram-php/blob/96df8089c4a68a35a7e82da79f087e6c2ca92316/src/Unstructured.php#L33-L68
|
225,096
|
SetBased/php-abc-table-detail
|
src/TableRow/Ipv4TableRow.php
|
Ipv4TableRow.addRow
|
public static function addRow(DetailTable $table, $header, ?string $ip4Address): void
{
if ($ip4Address!==null && $ip4Address!=='')
{
$table->addRow($header, ['class' => 'ipv4'], $ip4Address);
}
else
{
$table->addRow($header);
}
}
|
php
|
public static function addRow(DetailTable $table, $header, ?string $ip4Address): void
{
if ($ip4Address!==null && $ip4Address!=='')
{
$table->addRow($header, ['class' => 'ipv4'], $ip4Address);
}
else
{
$table->addRow($header);
}
}
|
[
"public",
"static",
"function",
"addRow",
"(",
"DetailTable",
"$",
"table",
",",
"$",
"header",
",",
"?",
"string",
"$",
"ip4Address",
")",
":",
"void",
"{",
"if",
"(",
"$",
"ip4Address",
"!==",
"null",
"&&",
"$",
"ip4Address",
"!==",
"''",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
",",
"[",
"'class'",
"=>",
"'ipv4'",
"]",
",",
"$",
"ip4Address",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
")",
";",
"}",
"}"
] |
Adds a row with a IPv4 value to a detail table.
@param DetailTable $table The detail table.
@param string|int|null $header The header text of this table row.
@param string|null $ip4Address The IPv4 address.
|
[
"Adds",
"a",
"row",
"with",
"a",
"IPv4",
"value",
"to",
"a",
"detail",
"table",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/Ipv4TableRow.php#L20-L30
|
225,097
|
975L/PaymentBundle
|
Twig/PaymentLink.php
|
PaymentLink.paymentLink
|
public function paymentLink(Environment $environment, $text = null, $amount = null, $currency = null)
{
return $environment->render('@c975LPayment/fragments/paymentLink.html.twig', array(
'text' => $text,
'amount' => $amount,
'currency' => strtolower($currency),
));
}
|
php
|
public function paymentLink(Environment $environment, $text = null, $amount = null, $currency = null)
{
return $environment->render('@c975LPayment/fragments/paymentLink.html.twig', array(
'text' => $text,
'amount' => $amount,
'currency' => strtolower($currency),
));
}
|
[
"public",
"function",
"paymentLink",
"(",
"Environment",
"$",
"environment",
",",
"$",
"text",
"=",
"null",
",",
"$",
"amount",
"=",
"null",
",",
"$",
"currency",
"=",
"null",
")",
"{",
"return",
"$",
"environment",
"->",
"render",
"(",
"'@c975LPayment/fragments/paymentLink.html.twig'",
",",
"array",
"(",
"'text'",
"=>",
"$",
"text",
",",
"'amount'",
"=>",
"$",
"amount",
",",
"'currency'",
"=>",
"strtolower",
"(",
"$",
"currency",
")",
",",
")",
")",
";",
"}"
] |
Returns xhtml code for Payment link
@return string
|
[
"Returns",
"xhtml",
"code",
"for",
"Payment",
"link"
] |
da3beb13842aea6a3dc278eeb565f519040995b7
|
https://github.com/975L/PaymentBundle/blob/da3beb13842aea6a3dc278eeb565f519040995b7/Twig/PaymentLink.php#L41-L48
|
225,098
|
SlayerBirden/dataflow
|
src/Pipe/Copy.php
|
Copy.pass
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$from = $dataBag[$this->from] ?? null;
$dataBag[$this->to] = $from;
return $dataBag;
}
|
php
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$from = $dataBag[$this->from] ?? null;
$dataBag[$this->to] = $from;
return $dataBag;
}
|
[
"public",
"function",
"pass",
"(",
"DataBagInterface",
"$",
"dataBag",
")",
":",
"DataBagInterface",
"{",
"$",
"from",
"=",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"from",
"]",
"??",
"null",
";",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"to",
"]",
"=",
"$",
"from",
";",
"return",
"$",
"dataBag",
";",
"}"
] |
Copy data from one key to another. Create if doesn't exist.
@param DataBagInterface $dataBag
@return DataBagInterface
|
[
"Copy",
"data",
"from",
"one",
"key",
"to",
"another",
".",
"Create",
"if",
"doesn",
"t",
"exist",
"."
] |
a9cb826b106e882e43523d39fea319adc4893e00
|
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Pipe/Copy.php#L39-L45
|
225,099
|
Erebot/API
|
src/Event/Match/TextAbstract.php
|
TextAbstract.setPattern
|
public function setPattern($pattern)
{
if (!\Erebot\Utils::stringifiable($pattern)) {
throw new \Erebot\InvalidValueException('Pattern must be a string');
}
$this->pattern = $pattern;
}
|
php
|
public function setPattern($pattern)
{
if (!\Erebot\Utils::stringifiable($pattern)) {
throw new \Erebot\InvalidValueException('Pattern must be a string');
}
$this->pattern = $pattern;
}
|
[
"public",
"function",
"setPattern",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"\\",
"Erebot",
"\\",
"Utils",
"::",
"stringifiable",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'Pattern must be a string'",
")",
";",
"}",
"$",
"this",
"->",
"pattern",
"=",
"$",
"pattern",
";",
"}"
] |
Sets the pattern associated with this filter.
\param string $pattern
Pattern to use in text comparisons.
\throw Erebot::InvalidValueException
The given value for $pattern is invalid.
|
[
"Sets",
"the",
"pattern",
"associated",
"with",
"this",
"filter",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Event/Match/TextAbstract.php#L78-L85
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.