repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
simplito/bn-php | lib/BN.php | BN.iushln | public function iushln($bits) {
assert(is_integer($bits) && $bits >= 0);
if ($bits < 54) {
$this->bi = $this->bi->mul(1 << $bits);
} else {
$this->bi = $this->bi->mul((new BigInteger(2))->pow($bits));
}
return $this;
} | php | public function iushln($bits) {
assert(is_integer($bits) && $bits >= 0);
if ($bits < 54) {
$this->bi = $this->bi->mul(1 << $bits);
} else {
$this->bi = $this->bi->mul((new BigInteger(2))->pow($bits));
}
return $this;
} | [
"public",
"function",
"iushln",
"(",
"$",
"bits",
")",
"{",
"assert",
"(",
"is_integer",
"(",
"$",
"bits",
")",
"&&",
"$",
"bits",
">=",
"0",
")",
";",
"if",
"(",
"$",
"bits",
"<",
"54",
")",
"{",
"$",
"this",
"->",
"bi",
"=",
"$",
"this",
"-... | Shift-left in-place | [
"Shift",
"-",
"left",
"in",
"-",
"place"
] | e852fcd27e4acbc32459606d7606e45a85e42465 | https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L340-L348 | train |
simplito/bn-php | lib/BN.php | BN.iaddn | public function iaddn($num) {
assert(is_numeric($num));
$this->bi = $this->bi->add(intval($num));
return $this;
} | php | public function iaddn($num) {
assert(is_numeric($num));
$this->bi = $this->bi->add(intval($num));
return $this;
} | [
"public",
"function",
"iaddn",
"(",
"$",
"num",
")",
"{",
"assert",
"(",
"is_numeric",
"(",
"$",
"num",
")",
")",
";",
"$",
"this",
"->",
"bi",
"=",
"$",
"this",
"->",
"bi",
"->",
"add",
"(",
"intval",
"(",
"$",
"num",
")",
")",
";",
"return",
... | Add plain number `num` to `this` | [
"Add",
"plain",
"number",
"num",
"to",
"this"
] | e852fcd27e4acbc32459606d7606e45a85e42465 | https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L420-L424 | train |
simplito/bn-php | lib/BN.php | BN.isubn | public function isubn($num) {
assert(is_numeric($num));
$this->bi = $this->bi->sub(intval($num));
return $this;
} | php | public function isubn($num) {
assert(is_numeric($num));
$this->bi = $this->bi->sub(intval($num));
return $this;
} | [
"public",
"function",
"isubn",
"(",
"$",
"num",
")",
"{",
"assert",
"(",
"is_numeric",
"(",
"$",
"num",
")",
")",
";",
"$",
"this",
"->",
"bi",
"=",
"$",
"this",
"->",
"bi",
"->",
"sub",
"(",
"intval",
"(",
"$",
"num",
")",
")",
";",
"return",
... | Subtract plain number `num` from `this` | [
"Subtract",
"plain",
"number",
"num",
"from",
"this"
] | e852fcd27e4acbc32459606d7606e45a85e42465 | https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L427-L431 | train |
simplito/bn-php | lib/BN.php | BN.mod | public function mod(BN $num) {
if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero());
$res = clone($this);
$res->bi = $res->bi->divR($num->bi);
return $res;
} | php | public function mod(BN $num) {
if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero());
$res = clone($this);
$res->bi = $res->bi->divR($num->bi);
return $res;
} | [
"public",
"function",
"mod",
"(",
"BN",
"$",
"num",
")",
"{",
"if",
"(",
"assert_options",
"(",
"ASSERT_ACTIVE",
")",
")",
"assert",
"(",
"!",
"$",
"num",
"->",
"isZero",
"(",
")",
")",
";",
"$",
"res",
"=",
"clone",
"(",
"$",
"this",
")",
";",
... | Find `this` % `num` | [
"Find",
"this",
"%",
"num"
] | e852fcd27e4acbc32459606d7606e45a85e42465 | https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L464-L469 | train |
simplito/bn-php | lib/BN.php | BN.idivn | public function idivn($num) {
assert(is_numeric($num) && $num != 0);
$this->bi = $this->bi->div(intval($num));
return $this;
} | php | public function idivn($num) {
assert(is_numeric($num) && $num != 0);
$this->bi = $this->bi->div(intval($num));
return $this;
} | [
"public",
"function",
"idivn",
"(",
"$",
"num",
")",
"{",
"assert",
"(",
"is_numeric",
"(",
"$",
"num",
")",
"&&",
"$",
"num",
"!=",
"0",
")",
";",
"$",
"this",
"->",
"bi",
"=",
"$",
"this",
"->",
"bi",
"->",
"div",
"(",
"intval",
"(",
"$",
"... | In-place division by number | [
"In",
"-",
"place",
"division",
"by",
"number"
] | e852fcd27e4acbc32459606d7606e45a85e42465 | https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L501-L505 | train |
Kirouane/interval | src/Rule/Interval/NeighborhoodAfter.php | NeighborhoodAfter.assert | public function assert(Interval $first, Interval $second): bool
{
return $first->getStart()->equalTo($second->getEnd());
} | php | public function assert(Interval $first, Interval $second): bool
{
return $first->getStart()->equalTo($second->getEnd());
} | [
"public",
"function",
"assert",
"(",
"Interval",
"$",
"first",
",",
"Interval",
"$",
"second",
")",
":",
"bool",
"{",
"return",
"$",
"first",
"->",
"getStart",
"(",
")",
"->",
"equalTo",
"(",
"$",
"second",
"->",
"getEnd",
"(",
")",
")",
";",
"}"
] | Returns true if the second interval is neighbor of the first one
@param Interval $first
@param Interval $second
@return bool | [
"Returns",
"true",
"if",
"the",
"second",
"interval",
"is",
"neighbor",
"of",
"the",
"first",
"one"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Rule/Interval/NeighborhoodAfter.php#L20-L23 | train |
Kirouane/interval | src/Parser/IntervalParser.php | IntervalParser.parse | public function parse(string $expression): Interval
{
$parse = \explode(',', $expression);
if (self::BOUNDARIES !== count($parse)) {
throw new \ErrorException('Parse interval expression');
}
$startTerm = \reset($parse);
$endTerm = \end($parse);
$startTerm = $this->parseStartTerm($startTerm);
$endTerm = $this->parseEndTerm($endTerm);
return new Interval(
$startTerm,
$endTerm
);
} | php | public function parse(string $expression): Interval
{
$parse = \explode(',', $expression);
if (self::BOUNDARIES !== count($parse)) {
throw new \ErrorException('Parse interval expression');
}
$startTerm = \reset($parse);
$endTerm = \end($parse);
$startTerm = $this->parseStartTerm($startTerm);
$endTerm = $this->parseEndTerm($endTerm);
return new Interval(
$startTerm,
$endTerm
);
} | [
"public",
"function",
"parse",
"(",
"string",
"$",
"expression",
")",
":",
"Interval",
"{",
"$",
"parse",
"=",
"\\",
"explode",
"(",
"','",
",",
"$",
"expression",
")",
";",
"if",
"(",
"self",
"::",
"BOUNDARIES",
"!==",
"count",
"(",
"$",
"parse",
")... | Create a Interval from an expression
@param string $expression
@return Interval
@throws \InvalidArgumentException
@throws \UnexpectedValueException
@throws \RangeException
@throws \ErrorException | [
"Create",
"a",
"Interval",
"from",
"an",
"expression"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L31-L48 | train |
Kirouane/interval | src/Parser/IntervalParser.php | IntervalParser.parseStartTerm | private function parseStartTerm(string $startTerm)
{
if ('' === $startTerm) {
throw new \ErrorException('Parse interval expression');
}
$startInclusion = $startTerm[0];
if (!\in_array($startInclusion, [self::LEFT, self::RIGHT], true)) {
throw new \ErrorException('Parse interval expression');
}
$isOpen = $startInclusion === self::LEFT;
$startValue = \substr($startTerm, 1);
return $this->parseValue($startValue, true, $isOpen);
} | php | private function parseStartTerm(string $startTerm)
{
if ('' === $startTerm) {
throw new \ErrorException('Parse interval expression');
}
$startInclusion = $startTerm[0];
if (!\in_array($startInclusion, [self::LEFT, self::RIGHT], true)) {
throw new \ErrorException('Parse interval expression');
}
$isOpen = $startInclusion === self::LEFT;
$startValue = \substr($startTerm, 1);
return $this->parseValue($startValue, true, $isOpen);
} | [
"private",
"function",
"parseStartTerm",
"(",
"string",
"$",
"startTerm",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"startTerm",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Parse interval expression'",
")",
";",
"}",
"$",
"startInclusion",
"=",
"$"... | Parses the start term
@param string $startTerm
@return float|int|string
@throws \InvalidArgumentException
@throws \ErrorException | [
"Parses",
"the",
"start",
"term"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L57-L72 | train |
Kirouane/interval | src/Parser/IntervalParser.php | IntervalParser.parseEndTerm | private function parseEndTerm(string $endTerm)
{
if ('' === $endTerm) {
throw new \ErrorException('Parse interval expression');
}
$endInclusion = \substr($endTerm, -1);
if (!\in_array($endInclusion, [self::LEFT, self::RIGHT], true)) {
throw new \ErrorException('Parse interval expression');
}
$isOpen = $endInclusion === self::RIGHT;
$endValue = \substr($endTerm, 0, -1);
return $this->parseValue($endValue, false, $isOpen);
} | php | private function parseEndTerm(string $endTerm)
{
if ('' === $endTerm) {
throw new \ErrorException('Parse interval expression');
}
$endInclusion = \substr($endTerm, -1);
if (!\in_array($endInclusion, [self::LEFT, self::RIGHT], true)) {
throw new \ErrorException('Parse interval expression');
}
$isOpen = $endInclusion === self::RIGHT;
$endValue = \substr($endTerm, 0, -1);
return $this->parseValue($endValue, false, $isOpen);
} | [
"private",
"function",
"parseEndTerm",
"(",
"string",
"$",
"endTerm",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"endTerm",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Parse interval expression'",
")",
";",
"}",
"$",
"endInclusion",
"=",
"\\",
"su... | Pareses the end term
@param string $endTerm
@return float|int|string
@throws \InvalidArgumentException
@throws \ErrorException | [
"Pareses",
"the",
"end",
"term"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L81-L96 | train |
Kirouane/interval | src/Parser/IntervalParser.php | IntervalParser.parseValue | private function parseValue($value, bool $isLeft, bool $isOpen)
{
if ($this->isInt($value)) {
return new Integer((int)$value, $isLeft, $isOpen);
}
if ($this->isInfinity($value)) {
$value = '-INF' === $value ? -\INF : \INF;
return new Infinity($value, $isLeft, $isOpen);
}
if ($this->isFloat($value)) {
return new Real((float)$value, $isLeft, $isOpen);
}
if ($this->isDate($value)) {
$value = \DateTimeImmutable::createFromFormat('U', (string)\strtotime($value));
$value = $value->setTimezone(new \DateTimeZone(\date_default_timezone_get()));
return new DateTime($value, $isLeft, $isOpen);
}
throw new \InvalidArgumentException('Unexpected $value type');
} | php | private function parseValue($value, bool $isLeft, bool $isOpen)
{
if ($this->isInt($value)) {
return new Integer((int)$value, $isLeft, $isOpen);
}
if ($this->isInfinity($value)) {
$value = '-INF' === $value ? -\INF : \INF;
return new Infinity($value, $isLeft, $isOpen);
}
if ($this->isFloat($value)) {
return new Real((float)$value, $isLeft, $isOpen);
}
if ($this->isDate($value)) {
$value = \DateTimeImmutable::createFromFormat('U', (string)\strtotime($value));
$value = $value->setTimezone(new \DateTimeZone(\date_default_timezone_get()));
return new DateTime($value, $isLeft, $isOpen);
}
throw new \InvalidArgumentException('Unexpected $value type');
} | [
"private",
"function",
"parseValue",
"(",
"$",
"value",
",",
"bool",
"$",
"isLeft",
",",
"bool",
"$",
"isOpen",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isInt",
"(",
"$",
"value",
")",
")",
"{",
"return",
"new",
"Integer",
"(",
"(",
"int",
")",
"... | Cast a value to its expected type
@param mixed $value
@param bool $isLeft
@param bool $isOpen
@return float|int|string
@throws \InvalidArgumentException | [
"Cast",
"a",
"value",
"to",
"its",
"expected",
"type"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L106-L128 | train |
Kirouane/interval | src/Parser/IntervalParser.php | IntervalParser.isInt | private function isInt(string $value): bool
{
return \is_numeric($value) && (float)\round($value, 0) === (float)$value;
} | php | private function isInt(string $value): bool
{
return \is_numeric($value) && (float)\round($value, 0) === (float)$value;
} | [
"private",
"function",
"isInt",
"(",
"string",
"$",
"value",
")",
":",
"bool",
"{",
"return",
"\\",
"is_numeric",
"(",
"$",
"value",
")",
"&&",
"(",
"float",
")",
"\\",
"round",
"(",
"$",
"value",
",",
"0",
")",
"===",
"(",
"float",
")",
"$",
"va... | Returns true if the value is an integer
@param $value
@return bool | [
"Returns",
"true",
"if",
"the",
"value",
"is",
"an",
"integer"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L135-L138 | train |
Kirouane/interval | src/Intervals.php | Intervals.exclude | public function exclude(Intervals $intervals) : Intervals
{
/** @var \Interval\Operation\Intervals\Exclusion $operation */
$operation = self::$di->get(Di::OPERATION_INTERVALS_EXCLUSION);
return $operation($this, $intervals);
} | php | public function exclude(Intervals $intervals) : Intervals
{
/** @var \Interval\Operation\Intervals\Exclusion $operation */
$operation = self::$di->get(Di::OPERATION_INTERVALS_EXCLUSION);
return $operation($this, $intervals);
} | [
"public",
"function",
"exclude",
"(",
"Intervals",
"$",
"intervals",
")",
":",
"Intervals",
"{",
"/** @var \\Interval\\Operation\\Intervals\\Exclusion $operation */",
"$",
"operation",
"=",
"self",
"::",
"$",
"di",
"->",
"get",
"(",
"Di",
"::",
"OPERATION_INTERVALS_EX... | Excludes this interval from another one. Exp
|________________________________________________________________________________|
-
|_________________| |_________________|
=
|___________| |___________________| |____________|
@param Intervals $intervals
@return Intervals | [
"Excludes",
"this",
"interval",
"from",
"another",
"one",
".",
"Exp"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Intervals.php#L65-L70 | train |
Kirouane/interval | src/Interval.php | Interval.toComparable | public static function toComparable($boundary)
{
$isInternallyType = \is_numeric($boundary) || \is_bool($boundary) || \is_string($boundary);
$comparable = null;
if ($isInternallyType) {
$comparable = $boundary;
} elseif ($boundary instanceof \DateTimeInterface) {
$comparable = $boundary->getTimestamp();
} else {
throw new \UnexpectedValueException('Unexpected boundary type');
}
return $comparable;
} | php | public static function toComparable($boundary)
{
$isInternallyType = \is_numeric($boundary) || \is_bool($boundary) || \is_string($boundary);
$comparable = null;
if ($isInternallyType) {
$comparable = $boundary;
} elseif ($boundary instanceof \DateTimeInterface) {
$comparable = $boundary->getTimestamp();
} else {
throw new \UnexpectedValueException('Unexpected boundary type');
}
return $comparable;
} | [
"public",
"static",
"function",
"toComparable",
"(",
"$",
"boundary",
")",
"{",
"$",
"isInternallyType",
"=",
"\\",
"is_numeric",
"(",
"$",
"boundary",
")",
"||",
"\\",
"is_bool",
"(",
"$",
"boundary",
")",
"||",
"\\",
"is_string",
"(",
"$",
"boundary",
... | Convert an boundary to comparable
@param mixed $boundary
@return mixed
@throws \UnexpectedValueException | [
"Convert",
"an",
"boundary",
"to",
"comparable"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Interval.php#L333-L347 | train |
Kirouane/interval | src/Rule/Interval/Overlapping.php | Overlapping.assert | public function assert(Interval $first, Interval $second): bool
{
return
$first->getEnd()->greaterThan($second->getStart()) &&
$first->getStart()->lessThan($second->getEnd());
} | php | public function assert(Interval $first, Interval $second): bool
{
return
$first->getEnd()->greaterThan($second->getStart()) &&
$first->getStart()->lessThan($second->getEnd());
} | [
"public",
"function",
"assert",
"(",
"Interval",
"$",
"first",
",",
"Interval",
"$",
"second",
")",
":",
"bool",
"{",
"return",
"$",
"first",
"->",
"getEnd",
"(",
")",
"->",
"greaterThan",
"(",
"$",
"second",
"->",
"getStart",
"(",
")",
")",
"&&",
"$... | Returns true if the second interval overlaps the first one
@param Interval $first
@param Interval $second
@return bool | [
"Returns",
"true",
"if",
"the",
"second",
"interval",
"overlaps",
"the",
"first",
"one"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Rule/Interval/Overlapping.php#L20-L25 | train |
Kirouane/interval | src/Operation/Interval/Intersection.php | Intersection.compute | public function compute(Interval $first, Interval $second): ?Interval
{
if ($first->isNeighborBefore($second)) {
return new Interval(
$first->getEnd()->changeSide(),
$second->getStart()->changeSide()
);
}
if ($first->isNeighborAfter($second)) {
return new Interval(
$second->getEnd()->changeSide(),
$first->getStart()->changeSide()
);
}
if (!$first->overlaps($second)) {
return null;
}
return new Interval(
$first->getStart()->greaterThan($second->getStart()) ? $first->getStart() : $second->getStart(),
$first->getEnd()->lessThan($second->getEnd()) ? $first->getEnd() : $second->getEnd()
);
} | php | public function compute(Interval $first, Interval $second): ?Interval
{
if ($first->isNeighborBefore($second)) {
return new Interval(
$first->getEnd()->changeSide(),
$second->getStart()->changeSide()
);
}
if ($first->isNeighborAfter($second)) {
return new Interval(
$second->getEnd()->changeSide(),
$first->getStart()->changeSide()
);
}
if (!$first->overlaps($second)) {
return null;
}
return new Interval(
$first->getStart()->greaterThan($second->getStart()) ? $first->getStart() : $second->getStart(),
$first->getEnd()->lessThan($second->getEnd()) ? $first->getEnd() : $second->getEnd()
);
} | [
"public",
"function",
"compute",
"(",
"Interval",
"$",
"first",
",",
"Interval",
"$",
"second",
")",
":",
"?",
"Interval",
"{",
"if",
"(",
"$",
"first",
"->",
"isNeighborBefore",
"(",
"$",
"second",
")",
")",
"{",
"return",
"new",
"Interval",
"(",
"$",... | Compute the intersection of two intervals. Exp
|_________________|
∩
|_________________|
=
|_____|
@param Interval $first
@param Interval $second
@return Interval
@throws \InvalidArgumentException
@throws \UnexpectedValueException
@throws \RangeException | [
"Compute",
"the",
"intersection",
"of",
"two",
"intervals",
".",
"Exp"
] | 8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8 | https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Operation/Interval/Intersection.php#L46-L70 | train |
TypistTech/wp-contained-hook | src/Loader.php | Loader.add | public function add(HookInterface ...$hooks): void
{
$this->hooks = array_values(
array_unique(
array_merge($this->hooks, $hooks),
SORT_REGULAR
)
);
} | php | public function add(HookInterface ...$hooks): void
{
$this->hooks = array_values(
array_unique(
array_merge($this->hooks, $hooks),
SORT_REGULAR
)
);
} | [
"public",
"function",
"add",
"(",
"HookInterface",
"...",
"$",
"hooks",
")",
":",
"void",
"{",
"$",
"this",
"->",
"hooks",
"=",
"array_values",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"hooks",
",",
"$",
"hooks",
")",
",",
"SORT... | Add new hooks to the collection to be registered with WordPress.
@param HookInterface|HookInterface[] ...$hooks Hooks to be registered.
@return void | [
"Add",
"new",
"hooks",
"to",
"the",
"collection",
"to",
"be",
"registered",
"with",
"WordPress",
"."
] | 0601190269f28877f2d21698f7fedebeb6bce738 | https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Loader.php#L45-L53 | train |
TypistTech/wp-contained-hook | src/Loader.php | Loader.run | public function run(): void
{
foreach ($this->hooks as $hook) {
$hook->setContainer($this->container);
$hook->register();
}
} | php | public function run(): void
{
foreach ($this->hooks as $hook) {
$hook->setContainer($this->container);
$hook->register();
}
} | [
"public",
"function",
"run",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"hooks",
"as",
"$",
"hook",
")",
"{",
"$",
"hook",
"->",
"setContainer",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"hook",
"->",
"register",
"(",
... | Register the hooks to the container and WordPress.
@return void | [
"Register",
"the",
"hooks",
"to",
"the",
"container",
"and",
"WordPress",
"."
] | 0601190269f28877f2d21698f7fedebeb6bce738 | https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Loader.php#L60-L66 | train |
TypistTech/wp-contained-hook | src/Hooks/Action.php | Action.run | public function run(...$args): void
{
$container = $this->getContainer();
$instance = $container->get($this->classIdentifier);
$instance->{$this->callbackMethod}(...$args);
} | php | public function run(...$args): void
{
$container = $this->getContainer();
$instance = $container->get($this->classIdentifier);
$instance->{$this->callbackMethod}(...$args);
} | [
"public",
"function",
"run",
"(",
"...",
"$",
"args",
")",
":",
"void",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
";",
"$",
"instance",
"=",
"$",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"classIdentifier",
")",... | The actual callback that WordPress going to fire.
@param mixed ...$args Arguments which pass on to the actual instance.
@return void | [
"The",
"actual",
"callback",
"that",
"WordPress",
"going",
"to",
"fire",
"."
] | 0601190269f28877f2d21698f7fedebeb6bce738 | https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Hooks/Action.php#L29-L35 | train |
clue/php-commander | src/Tokens/Tokenizer.php | Tokenizer.createToken | public function createToken($input)
{
$i = 0;
$token = $this->readAlternativeSentenceOrSingle($input, $i);
if (isset($input[$i])) {
throw new \InvalidArgumentException('Invalid root token, expression has superfluous contents');
}
return $token;
} | php | public function createToken($input)
{
$i = 0;
$token = $this->readAlternativeSentenceOrSingle($input, $i);
if (isset($input[$i])) {
throw new \InvalidArgumentException('Invalid root token, expression has superfluous contents');
}
return $token;
} | [
"public",
"function",
"createToken",
"(",
"$",
"input",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"readAlternativeSentenceOrSingle",
"(",
"$",
"input",
",",
"$",
"i",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"input",
"... | Creates a Token from the given route expression
@param string $input
@return TokenInterface
@throws InvalidArgumentException if the route expression can not be parsed | [
"Creates",
"a",
"Token",
"from",
"the",
"given",
"route",
"expression"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Tokens/Tokenizer.php#L43-L53 | train |
clue/php-commander | src/Tokens/Tokenizer.php | Tokenizer.readAlternativeSentenceOrSingle | private function readAlternativeSentenceOrSingle($input, &$i)
{
$tokens = array();
while (true) {
$tokens []= $this->readSentenceOrSingle($input, $i);
// end of input reached or end token found
if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) {
break;
}
// cursor now at alternative symbol (all other symbols are already handled)
// skip alternative mark and continue with next alternative
$i++;
}
// return a single token as-is
if (isset($tokens[0]) && !isset($tokens[1])) {
return $tokens[0];
}
return new AlternativeToken($tokens);
} | php | private function readAlternativeSentenceOrSingle($input, &$i)
{
$tokens = array();
while (true) {
$tokens []= $this->readSentenceOrSingle($input, $i);
// end of input reached or end token found
if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) {
break;
}
// cursor now at alternative symbol (all other symbols are already handled)
// skip alternative mark and continue with next alternative
$i++;
}
// return a single token as-is
if (isset($tokens[0]) && !isset($tokens[1])) {
return $tokens[0];
}
return new AlternativeToken($tokens);
} | [
"private",
"function",
"readAlternativeSentenceOrSingle",
"(",
"$",
"input",
",",
"&",
"$",
"i",
")",
"{",
"$",
"tokens",
"=",
"array",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"$",
"tokens",
"[",
"]",
"=",
"$",
"this",
"->",
"readSentenceOrSingl... | reads a complete sentence token until end of group
An "alternative sentence" may contain the following tokens:
- an alternative group (which may consist of individual sentences separated by `|`)
- a sentence (which may consist of multiple tokens)
- a single token
@param string $input
@param int $i
@throws InvalidArgumentException
@return TokenInterface | [
"reads",
"a",
"complete",
"sentence",
"token",
"until",
"end",
"of",
"group"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Tokens/Tokenizer.php#L188-L211 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Parser/DataParser.php | DataParser.timestampHasExpired | protected function timestampHasExpired($ts, $expire)
{
if (empty($expire)) {
return false;
}
$diff = time() - $ts;
if ($diff > $expire) {
return true;
}
return false;
} | php | protected function timestampHasExpired($ts, $expire)
{
if (empty($expire)) {
return false;
}
$diff = time() - $ts;
if ($diff > $expire) {
return true;
}
return false;
} | [
"protected",
"function",
"timestampHasExpired",
"(",
"$",
"ts",
",",
"$",
"expire",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"expire",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"diff",
"=",
"time",
"(",
")",
"-",
"$",
"ts",
";",
"if",
"(",
... | Check if given timestamp is expired.
@param int $ts
@return bool | [
"Check",
"if",
"given",
"timestamp",
"is",
"expired",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L97-L108 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Parser/DataParser.php | DataParser.parseSections | protected function parseSections()
{
foreach (array_keys($this->sections) as $section) {
// section headers
$header = new HeaderFilter($this->rawData);
$header->setFilter($section);
$headerData = $header->toArray();
$headerData = array_shift($headerData);
// skip section if no headers found
if (empty($headerData)) {
$this->log->debug("No header for section $section");
continue;
}
// save header separately
$this->results->append(
$this->scrubKey("{$section}_header"),
$headerData
);
// section data
$data = new SectionDataFilter($this->rawData);
$data->setFilter($section);
$data->setHeader($headerData);
$this->results->append(
$this->scrubKey($section),
$data
);
$this->log->debug("Parsed section '{$this->scrubKey($section)}'");
}
} | php | protected function parseSections()
{
foreach (array_keys($this->sections) as $section) {
// section headers
$header = new HeaderFilter($this->rawData);
$header->setFilter($section);
$headerData = $header->toArray();
$headerData = array_shift($headerData);
// skip section if no headers found
if (empty($headerData)) {
$this->log->debug("No header for section $section");
continue;
}
// save header separately
$this->results->append(
$this->scrubKey("{$section}_header"),
$headerData
);
// section data
$data = new SectionDataFilter($this->rawData);
$data->setFilter($section);
$data->setHeader($headerData);
$this->results->append(
$this->scrubKey($section),
$data
);
$this->log->debug("Parsed section '{$this->scrubKey($section)}'");
}
} | [
"protected",
"function",
"parseSections",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"sections",
")",
"as",
"$",
"section",
")",
"{",
"// section headers",
"$",
"header",
"=",
"new",
"HeaderFilter",
"(",
"$",
"this",
"->",
"rawDat... | Parse data sections. | [
"Parse",
"data",
"sections",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L113-L145 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Parser/DataParser.php | DataParser.convertTs | protected function convertTs($str)
{
if (empty($str) || strlen($str) != 14) {
return false;
}
$y = (int) substr($str, 0, 4);
$m = (int) substr($str, 4, 2);
$d = (int) substr($str, 6, 2);
$h = (int) substr($str, 8, 2);
$i = (int) substr($str, 10, 2);
$s = (int) substr($str, 12, 2);
$dt = new \DateTime();
$dt->setTimezone(new \DateTimeZone('UTC'));
$dt->setDate($y, $m, $d);
$dt->setTime($h, $i, $s);
return $dt->getTimestamp();
} | php | protected function convertTs($str)
{
if (empty($str) || strlen($str) != 14) {
return false;
}
$y = (int) substr($str, 0, 4);
$m = (int) substr($str, 4, 2);
$d = (int) substr($str, 6, 2);
$h = (int) substr($str, 8, 2);
$i = (int) substr($str, 10, 2);
$s = (int) substr($str, 12, 2);
$dt = new \DateTime();
$dt->setTimezone(new \DateTimeZone('UTC'));
$dt->setDate($y, $m, $d);
$dt->setTime($h, $i, $s);
return $dt->getTimestamp();
} | [
"protected",
"function",
"convertTs",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"str",
")",
"||",
"strlen",
"(",
"$",
"str",
")",
"!=",
"14",
")",
"{",
"return",
"false",
";",
"}",
"$",
"y",
"=",
"(",
"int",
")",
"substr",
"(",
... | Timestamp convertor to unix time.
@param string $str
@return int | [
"Timestamp",
"convertor",
"to",
"unix",
"time",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L197-L215 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Log/Logger.php | Logger.getHandler | protected function getHandler($file, $level)
{
if (empty(self::$handler)) {
$handler = new StreamHandler($file, $level);
$handler->setFormatter($this->getCustomFormatter());
self::$handler = $handler;
}
return self::$handler;
} | php | protected function getHandler($file, $level)
{
if (empty(self::$handler)) {
$handler = new StreamHandler($file, $level);
$handler->setFormatter($this->getCustomFormatter());
self::$handler = $handler;
}
return self::$handler;
} | [
"protected",
"function",
"getHandler",
"(",
"$",
"file",
",",
"$",
"level",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"handler",
")",
")",
"{",
"$",
"handler",
"=",
"new",
"StreamHandler",
"(",
"$",
"file",
",",
"$",
"level",
")",
";",
... | Get streamhandler.
@param string $file
@param int $level
@return \Monolog\Handler\StreamHandler | [
"Get",
"streamhandler",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/Logger.php#L62-L71 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.loadData | public function loadData()
{
$this->filePath = "{$this->cacheDir}/{$this->cacheFile}";
$this->validateConfig();
$urls = $this->prepareUrls($this->filePath, $this->urls, $this->forceRefresh, $this->cacheOnly);
// we need at least one location
if (!count($urls)) {
throw new SyncException(
'No location(s) available to sync from',
$this->errors
);
}
// cycle urls until valid data is found
while (count($urls) && empty($validData)) {
$nextUrl = array_shift($urls);
if ($this->getData($nextUrl)) {
$validData = true;
}
}
// we should have valid data at this point
if (!$this->parser->isValid() || empty($validData)) {
throw new SyncException(
'Unable to download data or data invalid',
$this->errors
);
}
return $this->parser->getParsedData();
} | php | public function loadData()
{
$this->filePath = "{$this->cacheDir}/{$this->cacheFile}";
$this->validateConfig();
$urls = $this->prepareUrls($this->filePath, $this->urls, $this->forceRefresh, $this->cacheOnly);
// we need at least one location
if (!count($urls)) {
throw new SyncException(
'No location(s) available to sync from',
$this->errors
);
}
// cycle urls until valid data is found
while (count($urls) && empty($validData)) {
$nextUrl = array_shift($urls);
if ($this->getData($nextUrl)) {
$validData = true;
}
}
// we should have valid data at this point
if (!$this->parser->isValid() || empty($validData)) {
throw new SyncException(
'Unable to download data or data invalid',
$this->errors
);
}
return $this->parser->getParsedData();
} | [
"public",
"function",
"loadData",
"(",
")",
"{",
"$",
"this",
"->",
"filePath",
"=",
"\"{$this->cacheDir}/{$this->cacheFile}\"",
";",
"$",
"this",
"->",
"validateConfig",
"(",
")",
";",
"$",
"urls",
"=",
"$",
"this",
"->",
"prepareUrls",
"(",
"$",
"this",
... | Return parsed data.
@throws SyncException
@return \Vatsimphp\Result\ResultContainer | [
"Return",
"parsed",
"data",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L184-L215 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.validateConfig | protected function validateConfig()
{
$this->validateUrls();
$this->validateRefreshInterval();
$this->validateCacheFile();
$this->validateFilePath();
$this->validateParser();
return true;
} | php | protected function validateConfig()
{
$this->validateUrls();
$this->validateRefreshInterval();
$this->validateCacheFile();
$this->validateFilePath();
$this->validateParser();
return true;
} | [
"protected",
"function",
"validateConfig",
"(",
")",
"{",
"$",
"this",
"->",
"validateUrls",
"(",
")",
";",
"$",
"this",
"->",
"validateRefreshInterval",
"(",
")",
";",
"$",
"this",
"->",
"validateCacheFile",
"(",
")",
";",
"$",
"this",
"->",
"validateFile... | Validate config wrapper. | [
"Validate",
"config",
"wrapper",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L286-L295 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.validateFilePath | protected function validateFilePath()
{
if (file_exists($this->filePath)) {
if (!is_writable($this->filePath)) {
throw new RuntimeException(
"File '{$this->filePath}' exist but is not writable"
);
}
} else {
if (!is_writable(dirname($this->filePath))) {
throw new RuntimeException(
"File '{$this->filePath}' is not writable"
);
}
}
} | php | protected function validateFilePath()
{
if (file_exists($this->filePath)) {
if (!is_writable($this->filePath)) {
throw new RuntimeException(
"File '{$this->filePath}' exist but is not writable"
);
}
} else {
if (!is_writable(dirname($this->filePath))) {
throw new RuntimeException(
"File '{$this->filePath}' is not writable"
);
}
}
} | [
"protected",
"function",
"validateFilePath",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"filePath",
")",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"this",
"->",
"filePath",
")",
")",
"{",
"throw",
"new",
"RuntimeException",... | Validate filePath.
@throws RuntimeException | [
"Validate",
"filePath",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L344-L359 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.initCurl | protected function initCurl()
{
if (empty($this->curl)) {
$this->curl = curl_init();
curl_setopt_array($this->curl, $this->curlOpts);
$this->log->debug('cURL object initialized', $this->curlOpts);
}
} | php | protected function initCurl()
{
if (empty($this->curl)) {
$this->curl = curl_init();
curl_setopt_array($this->curl, $this->curlOpts);
$this->log->debug('cURL object initialized', $this->curlOpts);
}
} | [
"protected",
"function",
"initCurl",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"curl",
")",
")",
"{",
"$",
"this",
"->",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt_array",
"(",
"$",
"this",
"->",
"curl",
",",
"$",
"this"... | Initialize curl resource. | [
"Initialize",
"curl",
"resource",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L378-L385 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.loadFromUrl | protected function loadFromUrl($url)
{
$url = $this->overrideUrl($url);
$this->log->debug("Load from url $url");
$this->initCurl();
curl_setopt($this->curl, CURLOPT_URL, $url);
if (!$data = $this->getDataFromCurl()) {
return false;
}
// fix encoding
$data = iconv('ISO-8859-15', 'UTF-8', $data);
// validate data through parser
if (!$this->isDataValid($data)) {
$this->addError($url, 'Data not valid according to parser');
return false;
}
// save result to disk
$this->saveToCache($data);
return true;
} | php | protected function loadFromUrl($url)
{
$url = $this->overrideUrl($url);
$this->log->debug("Load from url $url");
$this->initCurl();
curl_setopt($this->curl, CURLOPT_URL, $url);
if (!$data = $this->getDataFromCurl()) {
return false;
}
// fix encoding
$data = iconv('ISO-8859-15', 'UTF-8', $data);
// validate data through parser
if (!$this->isDataValid($data)) {
$this->addError($url, 'Data not valid according to parser');
return false;
}
// save result to disk
$this->saveToCache($data);
return true;
} | [
"protected",
"function",
"loadFromUrl",
"(",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"overrideUrl",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"\"Load from url $url\"",
")",
";",
"$",
"this",
"->",
"ini... | Load data from url and pass it to the parser
If successful save raw data to cache.
@param string $url
@return bool | [
"Load",
"data",
"from",
"url",
"and",
"pass",
"it",
"to",
"the",
"parser",
"If",
"successful",
"save",
"raw",
"data",
"to",
"cache",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L411-L435 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.getDataFromCurl | protected function getDataFromCurl()
{
$data = curl_exec($this->curl);
if (curl_errno($this->curl)) {
$this->addError(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL), curl_error($this->curl));
return false;
}
return $data;
} | php | protected function getDataFromCurl()
{
$data = curl_exec($this->curl);
if (curl_errno($this->curl)) {
$this->addError(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL), curl_error($this->curl));
return false;
}
return $data;
} | [
"protected",
"function",
"getDataFromCurl",
"(",
")",
"{",
"$",
"data",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"curl",
")",
";",
"if",
"(",
"curl_errno",
"(",
"$",
"this",
"->",
"curl",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"curl_geti... | Load data from curl resource.
@codeCoverageIgnore
@return false|string | [
"Load",
"data",
"from",
"curl",
"resource",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L444-L454 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.loadFromCache | protected function loadFromCache()
{
$this->log->debug("Load from cache file {$this->filePath}");
$data = $this->getDataFromFile();
if ($data === false) {
$data = '';
}
// validate data through parser
if (!$this->isDataValid($data)) {
$this->addError($this->filePath, 'Data not valid according to parser');
return false;
}
// verify if local cache is expired
if ($this->isCacheExpired()) {
$this->addError($this->filePath, 'Local cache is expired');
return false;
}
return true;
} | php | protected function loadFromCache()
{
$this->log->debug("Load from cache file {$this->filePath}");
$data = $this->getDataFromFile();
if ($data === false) {
$data = '';
}
// validate data through parser
if (!$this->isDataValid($data)) {
$this->addError($this->filePath, 'Data not valid according to parser');
return false;
}
// verify if local cache is expired
if ($this->isCacheExpired()) {
$this->addError($this->filePath, 'Local cache is expired');
return false;
}
return true;
} | [
"protected",
"function",
"loadFromCache",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"debug",
"(",
"\"Load from cache file {$this->filePath}\"",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getDataFromFile",
"(",
")",
";",
"if",
"(",
"$",
"data",
"=... | Load data from file and pass it to the parser
Fails if content is expired.
@return bool | [
"Load",
"data",
"from",
"file",
"and",
"pass",
"it",
"to",
"the",
"parser",
"Fails",
"if",
"content",
"is",
"expired",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L462-L485 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.isDataValid | protected function isDataValid($data)
{
$this->parser->setData($data);
$this->parser->parseData();
return $this->parser->isValid();
} | php | protected function isDataValid($data)
{
$this->parser->setData($data);
$this->parser->parseData();
return $this->parser->isValid();
} | [
"protected",
"function",
"isDataValid",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"parseData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"parser",
"->",
... | Validate the raw data using parser object.
@param string $data
@return bool | [
"Validate",
"the",
"raw",
"data",
"using",
"parser",
"object",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L506-L512 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.saveToCache | protected function saveToCache($data)
{
$fh = fopen($this->filePath, 'w');
if (flock($fh, LOCK_EX)) {
fwrite($fh, $data);
flock($fh, LOCK_UN);
}
fclose($fh);
$this->log->debug("Cache file {$this->filePath} saved");
} | php | protected function saveToCache($data)
{
$fh = fopen($this->filePath, 'w');
if (flock($fh, LOCK_EX)) {
fwrite($fh, $data);
flock($fh, LOCK_UN);
}
fclose($fh);
$this->log->debug("Cache file {$this->filePath} saved");
} | [
"protected",
"function",
"saveToCache",
"(",
"$",
"data",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"filePath",
",",
"'w'",
")",
";",
"if",
"(",
"flock",
"(",
"$",
"fh",
",",
"LOCK_EX",
")",
")",
"{",
"fwrite",
"(",
"$",
"fh",
... | Atomic save raw data to cache file.
@param string $data | [
"Atomic",
"save",
"raw",
"data",
"to",
"cache",
"file",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L519-L528 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/AbstractSync.php | AbstractSync.isCacheExpired | protected function isCacheExpired()
{
$ts = filemtime($this->filePath);
if (!$this->cacheOnly && time() - $ts >= $this->refreshInterval) {
$this->log->debug("Cache content {$this->filePath} expired ({$this->refreshInterval})");
return true;
}
return false;
} | php | protected function isCacheExpired()
{
$ts = filemtime($this->filePath);
if (!$this->cacheOnly && time() - $ts >= $this->refreshInterval) {
$this->log->debug("Cache content {$this->filePath} expired ({$this->refreshInterval})");
return true;
}
return false;
} | [
"protected",
"function",
"isCacheExpired",
"(",
")",
"{",
"$",
"ts",
"=",
"filemtime",
"(",
"$",
"this",
"->",
"filePath",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cacheOnly",
"&&",
"time",
"(",
")",
"-",
"$",
"ts",
">=",
"$",
"this",
"->",
... | Verify if file content is outdated based on
the file last modification timestamp.
@return bool | [
"Verify",
"if",
"file",
"content",
"is",
"outdated",
"based",
"on",
"the",
"file",
"last",
"modification",
"timestamp",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L536-L546 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Filter/AbstractFilter.php | AbstractFilter.isComment | protected function isComment($line)
{
if (is_string($line) && (substr($line, 0, 1) == ';' || trim($line) == '')) {
return true;
}
return false;
} | php | protected function isComment($line)
{
if (is_string($line) && (substr($line, 0, 1) == ';' || trim($line) == '')) {
return true;
}
return false;
} | [
"protected",
"function",
"isComment",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"line",
")",
"&&",
"(",
"substr",
"(",
"$",
"line",
",",
"0",
",",
"1",
")",
"==",
"';'",
"||",
"trim",
"(",
"$",
"line",
")",
"==",
"''",
")",
... | Check if current element is a comment.
@params mixed $line
@return bool | [
"Check",
"if",
"current",
"element",
"is",
"a",
"comment",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Filter/AbstractFilter.php#L139-L146 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/BaseSync.php | BaseSync.registerUrlFromStatus | public function registerUrlFromStatus(\Vatsimphp\Sync\StatusSync $sync, $type)
{
$urls = $sync->loadData()->get($type)->toArray();
if (empty($urls)) {
throw new RuntimeException(
'Error loading urls from StatusSync'
);
}
$this->registerUrl($urls, true);
return true;
} | php | public function registerUrlFromStatus(\Vatsimphp\Sync\StatusSync $sync, $type)
{
$urls = $sync->loadData()->get($type)->toArray();
if (empty($urls)) {
throw new RuntimeException(
'Error loading urls from StatusSync'
);
}
$this->registerUrl($urls, true);
return true;
} | [
"public",
"function",
"registerUrlFromStatus",
"(",
"\\",
"Vatsimphp",
"\\",
"Sync",
"\\",
"StatusSync",
"$",
"sync",
",",
"$",
"type",
")",
"{",
"$",
"urls",
"=",
"$",
"sync",
"->",
"loadData",
"(",
")",
"->",
"get",
"(",
"$",
"type",
")",
"->",
"to... | Use StatusSync to dynamically add the available
data urls to poll new data from.
@param \Vatsimphp\Sync\StatusSync $sync
@param string $type - the type of urls to use (ie dataUrls)
@throws \Vatsimphp\Exception\RuntimeException | [
"Use",
"StatusSync",
"to",
"dynamically",
"add",
"the",
"available",
"data",
"urls",
"to",
"poll",
"new",
"data",
"from",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/BaseSync.php#L42-L53 | train |
clue/php-commander | src/Router.php | Router.add | public function add($route, $handler)
{
if (trim($route) === '') {
$token = null;
} else {
$token = $this->tokenizer->createToken($route);
}
$route = new Route($token, $handler);
$this->routes[] = $route;
return $route;
} | php | public function add($route, $handler)
{
if (trim($route) === '') {
$token = null;
} else {
$token = $this->tokenizer->createToken($route);
}
$route = new Route($token, $handler);
$this->routes[] = $route;
return $route;
} | [
"public",
"function",
"add",
"(",
"$",
"route",
",",
"$",
"handler",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"route",
")",
"===",
"''",
")",
"{",
"$",
"token",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"tokenizer"... | Registers a new Route with this Router
@param string $route the route expression to match
@param callable $handler route callback that will be executed when this route expression matches
@return Route
@throws InvalidArgumentException if the route expression is invalid | [
"Registers",
"a",
"new",
"Route",
"with",
"this",
"Router"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L41-L53 | train |
clue/php-commander | src/Router.php | Router.remove | public function remove(Route $route)
{
$id = array_search($route, $this->routes);
if ($id === false) {
throw new \UnderflowException('Given Route not found');
}
unset($this->routes[$id]);
} | php | public function remove(Route $route)
{
$id = array_search($route, $this->routes);
if ($id === false) {
throw new \UnderflowException('Given Route not found');
}
unset($this->routes[$id]);
} | [
"public",
"function",
"remove",
"(",
"Route",
"$",
"route",
")",
"{",
"$",
"id",
"=",
"array_search",
"(",
"$",
"route",
",",
"$",
"this",
"->",
"routes",
")",
";",
"if",
"(",
"$",
"id",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"UnderflowExc... | Removes the given route object from the registered routes
@param Route $route
@throws \UnderflowException if the route does not exist | [
"Removes",
"the",
"given",
"route",
"object",
"from",
"the",
"registered",
"routes"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L61-L69 | train |
clue/php-commander | src/Router.php | Router.execArgv | public function execArgv(array $argv = null)
{
try {
$this->handleArgv($argv);
// @codeCoverageIgnoreStart
} catch (NoRouteFoundException $e) {
fwrite(STDERR, 'Usage Error: ' . $e->getMessage() . PHP_EOL);
// sysexits.h: #define EX_USAGE 64 /* command line usage error */
exit(64);
} catch (Exception $e) {
fwrite(STDERR, 'Program Error: ' . $e->getMessage() . PHP_EOL);
// stdlib.h: #define EXIT_FAILURE 1
exit(1);
}
// @codeCoverageIgnoreEnd
} | php | public function execArgv(array $argv = null)
{
try {
$this->handleArgv($argv);
// @codeCoverageIgnoreStart
} catch (NoRouteFoundException $e) {
fwrite(STDERR, 'Usage Error: ' . $e->getMessage() . PHP_EOL);
// sysexits.h: #define EX_USAGE 64 /* command line usage error */
exit(64);
} catch (Exception $e) {
fwrite(STDERR, 'Program Error: ' . $e->getMessage() . PHP_EOL);
// stdlib.h: #define EXIT_FAILURE 1
exit(1);
}
// @codeCoverageIgnoreEnd
} | [
"public",
"function",
"execArgv",
"(",
"array",
"$",
"argv",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"handleArgv",
"(",
"$",
"argv",
")",
";",
"// @codeCoverageIgnoreStart",
"}",
"catch",
"(",
"NoRouteFoundException",
"$",
"e",
")",
"{",
"f... | Executes by matching the `argv` against all registered routes and then exits
This is a convenience method that will match and execute a route and then
exit the program without returning.
If no route could be found or if the route callback throws an Exception,
it will print out an error message to STDERR and set an appropriate
non-zero exit code.
Note that this is for convenience only and only useful for the most
simple of all programs. If you need more control, then consider using
the underlying `handleArgv()` method and handle any error situations
yourself.
You can explicitly pass in your `argv` or it will automatically use the
values from the $_SERVER superglobal. The `argv` is an array that will
always start with the calling program as the first element. We simply
ignore this first element and then process the remaining elements
according to the registered routes.
@param array $argv
@uses self::handleArgv() | [
"Executes",
"by",
"matching",
"the",
"argv",
"against",
"all",
"registered",
"routes",
"and",
"then",
"exits"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L105-L122 | train |
clue/php-commander | src/Router.php | Router.handleArgv | public function handleArgv(array $argv = null)
{
if ($argv === null) {
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
}
array_shift($argv);
return $this->handleArgs($argv);
} | php | public function handleArgv(array $argv = null)
{
if ($argv === null) {
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
}
array_shift($argv);
return $this->handleArgs($argv);
} | [
"public",
"function",
"handleArgv",
"(",
"array",
"$",
"argv",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"argv",
"===",
"null",
")",
"{",
"$",
"argv",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'argv'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'argv'",
"]... | Executes by matching the `argv` against all registered routes and then returns
Unlike `execArgv()` this method will try to execute the route callback
and then return whatever the route callback returned.
If no route could be found or if the route callback throws an Exception,
it will throw an Exception.
You can explicitly pass in your `argv` or it will automatically use the
values from the $_SERVER superglobal. The `argv` is an array that will
always start with the calling program as the first element. We simply
ignore this first element and then process the remaining elements
according to the registered routes.
@param array|null $argv
@return mixed will be the return value from the matched route callback
@throws Exception if the executed route callback throws an exception
@throws NoRouteFoundException If no matching route could be found
@uses self::handleArgs() | [
"Executes",
"by",
"matching",
"the",
"argv",
"against",
"all",
"registered",
"routes",
"and",
"then",
"returns"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L145-L153 | train |
clue/php-commander | src/Router.php | Router.handleArgs | public function handleArgs(array $args)
{
foreach ($this->routes as $route) {
$input = $args;
$output = array();
if ($route->matches($input, $output)) {
return $route($output);
}
}
throw new NoRouteFoundException('No matching route found');
} | php | public function handleArgs(array $args)
{
foreach ($this->routes as $route) {
$input = $args;
$output = array();
if ($route->matches($input, $output)) {
return $route($output);
}
}
throw new NoRouteFoundException('No matching route found');
} | [
"public",
"function",
"handleArgs",
"(",
"array",
"$",
"args",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"route",
")",
"{",
"$",
"input",
"=",
"$",
"args",
";",
"$",
"output",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
... | Executes by matching the given args against all registered routes and then returns
Unlike `handleArgv()` this method will use the complete `$args` array
to match the registered routes (i.e. it will not ignore the first element).
This is particularly useful if you build this array yourself or if you
use an interactive command line interface (CLI) and ask your user to
supply the arguments.
The arguments have to be given as an array of individual elements. If you
only have a command line string that you want to split into an array of
individual command line arguments, consider using clue/arguments.
@param array $args
@return mixed will be the return value from the matched route callback
@throws Exception if the executed route callback throws an exception
@throws NoRouteFoundException If no matching route could be found | [
"Executes",
"by",
"matching",
"the",
"given",
"args",
"against",
"all",
"registered",
"routes",
"and",
"then",
"returns"
] | 9b28ac3f9b3d968c24255b0e484bb35e2fd5783c | https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L173-L184 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Log/LoggerFactory.php | LoggerFactory.get | public static function get($channel)
{
// in case an object is passed in we use the base class name as the channel
if (is_object($channel)) {
$ref = new \ReflectionClass($channel);
$channel = $ref->getShortName();
}
// custom log channels need to be registered in advance using self::register()
if (!self::channelExists($channel)) {
// use default logger object if set or fallback to builtin logger
if (self::channelExists(self::DEFAULT_LOGGER)) {
self::$loggers[$channel] = self::$loggers[self::DEFAULT_LOGGER];
} else {
$file = empty(self::$file) ? __DIR__.'/../../../app/logs/vatsimphp.log' : self::$file;
self::$loggers[$channel] = new Logger($channel, $file, self::$level);
}
}
return self::$loggers[$channel];
} | php | public static function get($channel)
{
// in case an object is passed in we use the base class name as the channel
if (is_object($channel)) {
$ref = new \ReflectionClass($channel);
$channel = $ref->getShortName();
}
// custom log channels need to be registered in advance using self::register()
if (!self::channelExists($channel)) {
// use default logger object if set or fallback to builtin logger
if (self::channelExists(self::DEFAULT_LOGGER)) {
self::$loggers[$channel] = self::$loggers[self::DEFAULT_LOGGER];
} else {
$file = empty(self::$file) ? __DIR__.'/../../../app/logs/vatsimphp.log' : self::$file;
self::$loggers[$channel] = new Logger($channel, $file, self::$level);
}
}
return self::$loggers[$channel];
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"channel",
")",
"{",
"// in case an object is passed in we use the base class name as the channel",
"if",
"(",
"is_object",
"(",
"$",
"channel",
")",
")",
"{",
"$",
"ref",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"... | Load logger object.
@param string|object $channel
@return \Psr\Log\LoggerInterface | [
"Load",
"logger",
"object",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/LoggerFactory.php#L63-L84 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Log/LoggerFactory.php | LoggerFactory.register | public static function register($channel, \Psr\Log\LoggerInterface $logger)
{
self::$loggers[$channel] = $logger;
return $logger;
} | php | public static function register($channel, \Psr\Log\LoggerInterface $logger)
{
self::$loggers[$channel] = $logger;
return $logger;
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"channel",
",",
"\\",
"Psr",
"\\",
"Log",
"\\",
"LoggerInterface",
"$",
"logger",
")",
"{",
"self",
"::",
"$",
"loggers",
"[",
"$",
"channel",
"]",
"=",
"$",
"logger",
";",
"return",
"$",
"logger",
... | Register log object for given channel.
@param string $channel
@param \Psr\Log\AbstractLogger $logger | [
"Register",
"log",
"object",
"for",
"given",
"channel",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/LoggerFactory.php#L92-L97 | train |
skymeyer/Vatsimphp | src/Vatsimphp/VatsimData.php | VatsimData.getMetar | public function getMetar($icao)
{
if ($this->loadMetar($icao)) {
$metar = $this->getArray('metar');
}
return (empty($metar)) ? '' : array_shift($metar);
} | php | public function getMetar($icao)
{
if ($this->loadMetar($icao)) {
$metar = $this->getArray('metar');
}
return (empty($metar)) ? '' : array_shift($metar);
} | [
"public",
"function",
"getMetar",
"(",
"$",
"icao",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loadMetar",
"(",
"$",
"icao",
")",
")",
"{",
"$",
"metar",
"=",
"$",
"this",
"->",
"getArray",
"(",
"'metar'",
")",
";",
"}",
"return",
"(",
"empty",
"("... | Get METAR.
@param string $icao
@return string | [
"Get",
"METAR",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L217-L224 | train |
skymeyer/Vatsimphp | src/Vatsimphp/VatsimData.php | VatsimData.loadData | public function loadData()
{
try {
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$data = $this->getDataSync();
$data->setDefaults();
$data->cacheDir = $this->config['cacheDir'];
$data->cacheOnly = $this->config['cacheOnly'];
$data->dataExpire = $this->config['dataExpire'];
$data->refreshInterval = $this->config['dataRefresh'];
$data->forceRefresh = $this->config['forceDataRefresh'];
// use statussync for non-cache mode
if (!$data->cacheOnly) {
$status = $this->prepareSync();
$data->registerUrlFromStatus($status, 'dataUrls');
}
$this->results = $data->loadData();
} catch (\Exception $e) {
$this->exceptionStack[] = $e;
return false;
}
return true;
} | php | public function loadData()
{
try {
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$data = $this->getDataSync();
$data->setDefaults();
$data->cacheDir = $this->config['cacheDir'];
$data->cacheOnly = $this->config['cacheOnly'];
$data->dataExpire = $this->config['dataExpire'];
$data->refreshInterval = $this->config['dataRefresh'];
$data->forceRefresh = $this->config['forceDataRefresh'];
// use statussync for non-cache mode
if (!$data->cacheOnly) {
$status = $this->prepareSync();
$data->registerUrlFromStatus($status, 'dataUrls');
}
$this->results = $data->loadData();
} catch (\Exception $e) {
$this->exceptionStack[] = $e;
return false;
}
return true;
} | [
"public",
"function",
"loadData",
"(",
")",
"{",
"try",
"{",
"LoggerFactory",
"::",
"$",
"file",
"=",
"$",
"this",
"->",
"config",
"[",
"'logFile'",
"]",
";",
"LoggerFactory",
"::",
"$",
"level",
"=",
"$",
"this",
"->",
"config",
"[",
"'logLevel'",
"]"... | Load data from Vatsim network.
@return bool | [
"Load",
"data",
"from",
"Vatsim",
"network",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L233-L260 | train |
skymeyer/Vatsimphp | src/Vatsimphp/VatsimData.php | VatsimData.loadMetar | public function loadMetar($icao)
{
try {
$metar = $this->prepareMetarSync();
$metar->setAirport($icao);
$this->results = $metar->loadData();
} catch (\Exception $e) {
$this->exceptionStack[] = $e;
return false;
}
return true;
} | php | public function loadMetar($icao)
{
try {
$metar = $this->prepareMetarSync();
$metar->setAirport($icao);
$this->results = $metar->loadData();
} catch (\Exception $e) {
$this->exceptionStack[] = $e;
return false;
}
return true;
} | [
"public",
"function",
"loadMetar",
"(",
"$",
"icao",
")",
"{",
"try",
"{",
"$",
"metar",
"=",
"$",
"this",
"->",
"prepareMetarSync",
"(",
")",
";",
"$",
"metar",
"->",
"setAirport",
"(",
"$",
"icao",
")",
";",
"$",
"this",
"->",
"results",
"=",
"$"... | Load METAR data for given airport.
@param string $icao
@return bool | [
"Load",
"METAR",
"data",
"for",
"given",
"airport",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L269-L282 | train |
skymeyer/Vatsimphp | src/Vatsimphp/VatsimData.php | VatsimData.prepareSync | protected function prepareSync()
{
if (!empty($this->statusSync)) {
return $this->statusSync;
}
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$this->statusSync = $this->getStatusSync();
$this->statusSync->setDefaults();
$this->statusSync->cacheDir = $this->config['cacheDir'];
$this->statusSync->refreshInterval = $this->config['statusRefresh'];
if (!empty($this->config['statusUrl'])) {
$this->statusSync->registerUrl($this->config['statusUrl'], true);
}
return $this->statusSync;
} | php | protected function prepareSync()
{
if (!empty($this->statusSync)) {
return $this->statusSync;
}
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$this->statusSync = $this->getStatusSync();
$this->statusSync->setDefaults();
$this->statusSync->cacheDir = $this->config['cacheDir'];
$this->statusSync->refreshInterval = $this->config['statusRefresh'];
if (!empty($this->config['statusUrl'])) {
$this->statusSync->registerUrl($this->config['statusUrl'], true);
}
return $this->statusSync;
} | [
"protected",
"function",
"prepareSync",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"statusSync",
")",
")",
"{",
"return",
"$",
"this",
"->",
"statusSync",
";",
"}",
"LoggerFactory",
"::",
"$",
"file",
"=",
"$",
"this",
"->",
"con... | Prepare StatusSync object for reusage.
@return StatusSync | [
"Prepare",
"StatusSync",
"object",
"for",
"reusage",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L388-L404 | train |
skymeyer/Vatsimphp | src/Vatsimphp/VatsimData.php | VatsimData.prepareMetarSync | protected function prepareMetarSync()
{
if (!empty($this->metarSync)) {
return $this->metarSync;
}
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$this->metarSync = $this->getMetarSync();
$this->metarSync->setDefaults();
$this->metarSync->cacheDir = $this->config['cacheDir'];
$this->metarSync->cacheOnly = false;
$this->metarSync->refreshInterval = $this->config['metarRefresh'];
$this->metarSync->forceRefresh = $this->config['forceMetarRefresh'];
$this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls');
return $this->metarSync;
} | php | protected function prepareMetarSync()
{
if (!empty($this->metarSync)) {
return $this->metarSync;
}
LoggerFactory::$file = $this->config['logFile'];
LoggerFactory::$level = $this->config['logLevel'];
$this->metarSync = $this->getMetarSync();
$this->metarSync->setDefaults();
$this->metarSync->cacheDir = $this->config['cacheDir'];
$this->metarSync->cacheOnly = false;
$this->metarSync->refreshInterval = $this->config['metarRefresh'];
$this->metarSync->forceRefresh = $this->config['forceMetarRefresh'];
$this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls');
return $this->metarSync;
} | [
"protected",
"function",
"prepareMetarSync",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"metarSync",
")",
")",
"{",
"return",
"$",
"this",
"->",
"metarSync",
";",
"}",
"LoggerFactory",
"::",
"$",
"file",
"=",
"$",
"this",
"->",
"... | Prepare MetarSync object for reusage.
@return MetarSync | [
"Prepare",
"MetarSync",
"object",
"for",
"reusage",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L411-L427 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Parser/AbstractParser.php | AbstractParser.setData | public function setData($data)
{
$this->valid = false;
$this->hash = md5($data, false);
$this->rawData = explode("\n", $data);
} | php | public function setData($data)
{
$this->valid = false;
$this->hash = md5($data, false);
$this->rawData = explode("\n", $data);
} | [
"public",
"function",
"setData",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"valid",
"=",
"false",
";",
"$",
"this",
"->",
"hash",
"=",
"md5",
"(",
"$",
"data",
",",
"false",
")",
";",
"$",
"this",
"->",
"rawData",
"=",
"explode",
"(",
"\"\\n... | Set raw data.
@param string $data | [
"Set",
"raw",
"data",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/AbstractParser.php#L80-L85 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Result/ResultContainer.php | ResultContainer.get | public function get($name)
{
if (isset($this->container[$name])) {
return $this->container[$name];
} else {
return new Iterator([]);
}
} | php | public function get($name)
{
if (isset($this->container[$name])) {
return $this->container[$name];
} else {
return new Iterator([]);
}
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"ret... | Get result object from container.
@param string $name
@return \Vatsimphp\Filter\AbstractFilter | [
"Get",
"result",
"object",
"from",
"container",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Result/ResultContainer.php#L80-L87 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Result/ResultContainer.php | ResultContainer.search | public function search($objectType, $query = [])
{
$results = [];
if ($this->isSearchable($objectType)) {
foreach ($this->get($objectType) as $line) {
foreach ($query as $field => $needle) {
if (isset($line[$field])) {
if (stripos($line[$field], $needle) !== false) {
$results[] = $line;
}
}
}
}
}
return new Iterator($results);
} | php | public function search($objectType, $query = [])
{
$results = [];
if ($this->isSearchable($objectType)) {
foreach ($this->get($objectType) as $line) {
foreach ($query as $field => $needle) {
if (isset($line[$field])) {
if (stripos($line[$field], $needle) !== false) {
$results[] = $line;
}
}
}
}
}
return new Iterator($results);
} | [
"public",
"function",
"search",
"(",
"$",
"objectType",
",",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isSearchable",
"(",
"$",
"objectType",
")",
")",
"{",
"foreach",
"(",
"$",
"thi... | Base search functionality.
@param string $objectType
@param array $query
@return \Vatsimphp\Filter\Iterator | [
"Base",
"search",
"functionality",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Result/ResultContainer.php#L115-L131 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Filter/SectionDataFilter.php | SectionDataFilter.fixData | protected function fixData($data)
{
$addCols = count($this->header) - count($data);
for ($i = 1; $i <= $addCols; $i++) {
$data[] = '';
}
return $data;
} | php | protected function fixData($data)
{
$addCols = count($this->header) - count($data);
for ($i = 1; $i <= $addCols; $i++) {
$data[] = '';
}
return $data;
} | [
"protected",
"function",
"fixData",
"(",
"$",
"data",
")",
"{",
"$",
"addCols",
"=",
"count",
"(",
"$",
"this",
"->",
"header",
")",
"-",
"count",
"(",
"$",
"data",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"addCols",
... | Fix data points.
It seems some data points are empty at the end
which got truncated in the data resulting in an
offset between header and actual data points.
This method corrects the data by adding missing
empty values at the end.
@param array $data
@return array | [
"Fix",
"data",
"points",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Filter/SectionDataFilter.php#L88-L96 | train |
wpreadme2markdown/wp-readme-to-markdown | src/Converter.php | Converter.findScreenshot | private static function findScreenshot($number, $plugin_slug)
{
$extensions = array('png', 'jpg', 'jpeg', 'gif');
// this seems to now be the correct URL, not s.wordpress.org/plugins
$base_url = 'https://s.w.org/plugins/' . $plugin_slug . '/';
$assets_url = 'https://ps.w.org/' . $plugin_slug . '/assets/';
/* check assets for all extensions first, because if there's a
gif in the assets directory and a jpg in the base directory,
the one in the assets directory needs to win.
*/
foreach (array($assets_url, $base_url) as $prefix_url) {
foreach ($extensions as $ext) {
$url = $prefix_url . 'screenshot-' . $number . '.' . $ext;
if (self::validateUrl($url)) {
return $url;
}
}
}
return false;
} | php | private static function findScreenshot($number, $plugin_slug)
{
$extensions = array('png', 'jpg', 'jpeg', 'gif');
// this seems to now be the correct URL, not s.wordpress.org/plugins
$base_url = 'https://s.w.org/plugins/' . $plugin_slug . '/';
$assets_url = 'https://ps.w.org/' . $plugin_slug . '/assets/';
/* check assets for all extensions first, because if there's a
gif in the assets directory and a jpg in the base directory,
the one in the assets directory needs to win.
*/
foreach (array($assets_url, $base_url) as $prefix_url) {
foreach ($extensions as $ext) {
$url = $prefix_url . 'screenshot-' . $number . '.' . $ext;
if (self::validateUrl($url)) {
return $url;
}
}
}
return false;
} | [
"private",
"static",
"function",
"findScreenshot",
"(",
"$",
"number",
",",
"$",
"plugin_slug",
")",
"{",
"$",
"extensions",
"=",
"array",
"(",
"'png'",
",",
"'jpg'",
",",
"'jpeg'",
",",
"'gif'",
")",
";",
"// this seems to now be the correct URL, not s.wordpress.... | Finds the correct screenshot file with the given number and plugin slug.
As per the WordPress plugin repo, file extensions may be any
of: (png|jpg|jpeg|gif). We look in the /assets directory first,
then in the base directory.
@param int $number Screenshot number to look for
@param string $plugin_slug
@return string|false Valid screenshot URL or false if none found
@uses url_validate
@link http://wordpress.org/plugins/about/readme.txt | [
"Finds",
"the",
"correct",
"screenshot",
"file",
"with",
"the",
"given",
"number",
"and",
"plugin",
"slug",
"."
] | 7f92cb393eb1265baea8a5c2391ac2d0490e1f40 | https://github.com/wpreadme2markdown/wp-readme-to-markdown/blob/7f92cb393eb1265baea8a5c2391ac2d0490e1f40/src/Converter.php#L92-L114 | train |
wpreadme2markdown/wp-readme-to-markdown | src/Converter.php | Converter.validateUrl | private static function validateUrl($link)
{
$url_parts = @parse_url($link);
if (empty($url_parts['host'])) {
return false;
}
$host = $url_parts['host'];
if (!empty($url_parts['path'])) {
$documentpath = $url_parts['path'];
} else {
$documentpath = '/';
}
if (!empty($url_parts['query'])) {
$documentpath .= '?' . $url_parts['query'];
}
if (!empty($url_parts['port'])) {
$port = $url_parts['port'];
} else {
$port = '80';
}
$socket = @fsockopen($host, $port, $errno, $errstr, 30);
if (!$socket) {
return false;
} else {
fwrite($socket, "HEAD " . $documentpath . " HTTP/1.0\r\nHost: $host\r\n\r\n");
$http_response = fgets($socket, 22);
if (preg_match('/200 OK/', $http_response, $regs)) {
fclose($socket);
return true;
} else {
return false;
}
}
} | php | private static function validateUrl($link)
{
$url_parts = @parse_url($link);
if (empty($url_parts['host'])) {
return false;
}
$host = $url_parts['host'];
if (!empty($url_parts['path'])) {
$documentpath = $url_parts['path'];
} else {
$documentpath = '/';
}
if (!empty($url_parts['query'])) {
$documentpath .= '?' . $url_parts['query'];
}
if (!empty($url_parts['port'])) {
$port = $url_parts['port'];
} else {
$port = '80';
}
$socket = @fsockopen($host, $port, $errno, $errstr, 30);
if (!$socket) {
return false;
} else {
fwrite($socket, "HEAD " . $documentpath . " HTTP/1.0\r\nHost: $host\r\n\r\n");
$http_response = fgets($socket, 22);
if (preg_match('/200 OK/', $http_response, $regs)) {
fclose($socket);
return true;
} else {
return false;
}
}
} | [
"private",
"static",
"function",
"validateUrl",
"(",
"$",
"link",
")",
"{",
"$",
"url_parts",
"=",
"@",
"parse_url",
"(",
"$",
"link",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"url_parts",
"[",
"'host'",
"]",
")",
")",
"{",
"return",
"false",
";",
"... | Test whether a file exists at the given URL.
To do this as quickly as possible, we use fsockopen to just
get the HTTP headers and see if the response is "200 OK".
This is better than fopen (which would download the entire file)
and cURL (which might not be installed on all systems).
@param string $link URL to validate
@return boolean
@link http://www.php.net/manual/en/function.fsockopen.php#39948 | [
"Test",
"whether",
"a",
"file",
"exists",
"at",
"the",
"given",
"URL",
"."
] | 7f92cb393eb1265baea8a5c2391ac2d0490e1f40 | https://github.com/wpreadme2markdown/wp-readme-to-markdown/blob/7f92cb393eb1265baea8a5c2391ac2d0490e1f40/src/Converter.php#L128-L168 | train |
skymeyer/Vatsimphp | src/Vatsimphp/Sync/MetarSync.php | MetarSync.setAirport | public function setAirport($icao)
{
if (strlen($icao) != 4) {
throw new RuntimeException('invalid ICAO code');
}
$this->icao = strtoupper($icao);
$this->cacheFile = "metar-{$this->icao}.txt";
} | php | public function setAirport($icao)
{
if (strlen($icao) != 4) {
throw new RuntimeException('invalid ICAO code');
}
$this->icao = strtoupper($icao);
$this->cacheFile = "metar-{$this->icao}.txt";
} | [
"public",
"function",
"setAirport",
"(",
"$",
"icao",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"icao",
")",
"!=",
"4",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'invalid ICAO code'",
")",
";",
"}",
"$",
"this",
"->",
"icao",
"=",
"strtoupper"... | Set airport - cache file is based on this.
@param string $icao
@throws Vatsimphp\Exception\RuntimeException | [
"Set",
"airport",
"-",
"cache",
"file",
"is",
"based",
"on",
"this",
"."
] | cc458a3962f9512cb042d65972b99d88ef75164c | https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/MetarSync.php#L53-L60 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Permission.php | Permission.get | public function get($vhost, $user)
{
return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)));
} | php | public function get($vhost, $user)
{
return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)));
} | [
"public",
"function",
"get",
"(",
"$",
"vhost",
",",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/permissions/%s/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlencode",
"(",
"$",
"use... | An individual permission of a user and virtual host.
@param string $vhost
@param string $user
@return array | [
"An",
"individual",
"permission",
"of",
"a",
"user",
"and",
"virtual",
"host",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Permission.php#L31-L34 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Permission.php | Permission.delete | public function delete($vhost, $user)
{
return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)), 'DELETE');
} | php | public function delete($vhost, $user)
{
return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)), 'DELETE');
} | [
"public",
"function",
"delete",
"(",
"$",
"vhost",
",",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/permissions/%s/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlencode",
"(",
"$",
"... | Delete a specific set of permissions
@param string $vhost
@param string $user
@return array | [
"Delete",
"a",
"specific",
"set",
"of",
"permissions"
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Permission.php#L65-L68 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Policy.php | Policy.get | public function get($vhost, $name = null)
{
if ($name) {
return $this->client->send(sprintf('/api/policies/%s/%s', urlencode($vhost), urlencode($name)));
}
return $this->client->send(sprintf('/api/policies/%s', urlencode($vhost)));
} | php | public function get($vhost, $name = null)
{
if ($name) {
return $this->client->send(sprintf('/api/policies/%s/%s', urlencode($vhost), urlencode($name)));
}
return $this->client->send(sprintf('/api/policies/%s', urlencode($vhost)));
} | [
"public",
"function",
"get",
"(",
"$",
"vhost",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/policies/%s/%s'",
",",
"urlencode",
"(",
"$",
... | A list of all policies in a given virtual host.
OR
An individual policy.
@param string $vhost
@param string|null $name
@return array | [
"A",
"list",
"of",
"all",
"policies",
"in",
"a",
"given",
"virtual",
"host",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Policy.php#L33-L40 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Parameter.php | Parameter.get | public function get($component, $vhost = null, $name = null)
{
if ($vhost && $name) {
return $this->client->send(sprintf('/api/parameters/%s/%s/%s', urlencode($component), urlencode($vhost), urlencode($name)));
} elseif ($vhost) {
return $this->client->send(sprintf('/api/parameters/%s/%s', urlencode($component), urlencode($vhost)));
} else {
return $this->client->send(sprintf('/api/parameters/%s', urlencode($component)));
}
} | php | public function get($component, $vhost = null, $name = null)
{
if ($vhost && $name) {
return $this->client->send(sprintf('/api/parameters/%s/%s/%s', urlencode($component), urlencode($vhost), urlencode($name)));
} elseif ($vhost) {
return $this->client->send(sprintf('/api/parameters/%s/%s', urlencode($component), urlencode($vhost)));
} else {
return $this->client->send(sprintf('/api/parameters/%s', urlencode($component)));
}
} | [
"public",
"function",
"get",
"(",
"$",
"component",
",",
"$",
"vhost",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"vhost",
"&&",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf"... | A list of all parameters for a given component and virtual host.
@param string $component
@param string|null $vhost
@param string|null $name
@return array | [
"A",
"list",
"of",
"all",
"parameters",
"for",
"a",
"given",
"component",
"and",
"virtual",
"host",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Parameter.php#L30-L39 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Queue.php | Queue.bindings | public function bindings($vhost, $queue)
{
return $this->client->send(sprintf('/api/queues/%s/%s/bindings', urlencode($vhost), urlencode($queue)));
} | php | public function bindings($vhost, $queue)
{
return $this->client->send(sprintf('/api/queues/%s/%s/bindings', urlencode($vhost), urlencode($queue)));
} | [
"public",
"function",
"bindings",
"(",
"$",
"vhost",
",",
"$",
"queue",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/queues/%s/%s/bindings'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlencode",
"(",
"... | A list of all bindings on a given queue.
@param string $vhost
@param string $queue
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"on",
"a",
"given",
"queue",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Queue.php#L82-L85 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Queue.php | Queue.purgeMessages | public function purgeMessages($vhost, $name)
{
return $this->client->send(sprintf('/api/queues/%s/%s/contents', urlencode($vhost), urlencode($name)), 'DELETE');
} | php | public function purgeMessages($vhost, $name)
{
return $this->client->send(sprintf('/api/queues/%s/%s/contents', urlencode($vhost), urlencode($name)), 'DELETE');
} | [
"public",
"function",
"purgeMessages",
"(",
"$",
"vhost",
",",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/queues/%s/%s/contents'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlencode",
"(",... | Contents of a queue. DELETE to purge. Note you can't GET this.
@param string $vhost
@param string $name
@return array | [
"Contents",
"of",
"a",
"queue",
".",
"DELETE",
"to",
"purge",
".",
"Note",
"you",
"can",
"t",
"GET",
"this",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Queue.php#L94-L97 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Binding.php | Binding.all | public function all($vhost = null)
{
if ($vhost) {
return $this->client->send(sprintf('/api/bindings/%s', urlencode($vhost)));
} else {
return $this->client->send('/api/bindings');
}
} | php | public function all($vhost = null)
{
if ($vhost) {
return $this->client->send(sprintf('/api/bindings/%s', urlencode($vhost)));
} else {
return $this->client->send('/api/bindings');
}
} | [
"public",
"function",
"all",
"(",
"$",
"vhost",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"vhost",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/bindings/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
")",
... | A list of all bindings.
OR
A list of all bindings in a given virtual host.
@param string|null $vhost
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Binding.php#L20-L27 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Binding.php | Binding.binding | public function binding($vhost, $exchange, $queue)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/q/%s', urlencode($vhost), urlencode($exchange), urlencode($queue)));
} | php | public function binding($vhost, $exchange, $queue)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/q/%s', urlencode($vhost), urlencode($exchange), urlencode($queue)));
} | [
"public",
"function",
"binding",
"(",
"$",
"vhost",
",",
"$",
"exchange",
",",
"$",
"queue",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/bindings/%s/e/%s/q/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
","... | A list of all bindings between an exchange and a queue. Remember, an exchange and a queue can be bound together
many times!
@param string $vhost
@param string $exchange
@param string $queue
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"between",
"an",
"exchange",
"and",
"a",
"queue",
".",
"Remember",
"an",
"exchange",
"and",
"a",
"queue",
"can",
"be",
"bound",
"together",
"many",
"times!"
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Binding.php#L38-L41 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Binding.php | Binding.exchangeBinding | public function exchangeBinding($vhost, $source, $destination)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/e/%s', urlencode($vhost), urlencode($source), urlencode($destination)));
} | php | public function exchangeBinding($vhost, $source, $destination)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/e/%s', urlencode($vhost), urlencode($source), urlencode($destination)));
} | [
"public",
"function",
"exchangeBinding",
"(",
"$",
"vhost",
",",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/bindings/%s/e/%s/e/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
... | A list of all bindings between two exchanges. Remember, two exchanges can be bound together many times with
different parameters!
@param string $vhost
@param string $source
@param string $destination
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"between",
"two",
"exchanges",
".",
"Remember",
"two",
"exchanges",
"can",
"be",
"bound",
"together",
"many",
"times",
"with",
"different",
"parameters!"
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Binding.php#L53-L56 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Binding.php | Binding.delete | public function delete($vhost, $exchange, $queue, $props)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/q/%s/%s', urlencode($vhost), urlencode($exchange), urlencode($queue), urlencode($props)), 'DELETE');
} | php | public function delete($vhost, $exchange, $queue, $props)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/q/%s/%s', urlencode($vhost), urlencode($exchange), urlencode($queue), urlencode($props)), 'DELETE');
} | [
"public",
"function",
"delete",
"(",
"$",
"vhost",
",",
"$",
"exchange",
",",
"$",
"queue",
",",
"$",
"props",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/bindings/%s/e/%s/q/%s/%s'",
",",
"urlencode",
"(",
"... | Remove an individual binding between an exchange and a queue.
@param string $vhost
@param string $exchange
@param string $queue
@param string $props
@return array | [
"Remove",
"an",
"individual",
"binding",
"between",
"an",
"exchange",
"and",
"a",
"queue",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Binding.php#L163-L166 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Binding.php | Binding.deleteExchange | public function deleteExchange($vhost, $source, $destination, $props)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/e/%s/%s', urlencode($vhost), urlencode($source), urlencode($destination), urlencode($props)), 'DELETE');
} | php | public function deleteExchange($vhost, $source, $destination, $props)
{
return $this->client->send(sprintf('/api/bindings/%s/e/%s/e/%s/%s', urlencode($vhost), urlencode($source), urlencode($destination), urlencode($props)), 'DELETE');
} | [
"public",
"function",
"deleteExchange",
"(",
"$",
"vhost",
",",
"$",
"source",
",",
"$",
"destination",
",",
"$",
"props",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/bindings/%s/e/%s/e/%s/%s'",
",",
"urlencode"... | Remove an individual binding between two exchanges.
@param string $vhost
@param string $source
@param string $destination
@param string $props
@return array | [
"Remove",
"an",
"individual",
"binding",
"between",
"two",
"exchanges",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Binding.php#L177-L180 | train |
amphp/sync | lib/PosixSemaphore.php | PosixSemaphore.create | public static function create(string $id, int $maxLocks, int $permissions = 0600): self {
if ($maxLocks < 1) {
throw new \Error("Number of locks must be greater than 0");
}
$semaphore = new self($id);
$semaphore->init($maxLocks, $permissions);
return $semaphore;
} | php | public static function create(string $id, int $maxLocks, int $permissions = 0600): self {
if ($maxLocks < 1) {
throw new \Error("Number of locks must be greater than 0");
}
$semaphore = new self($id);
$semaphore->init($maxLocks, $permissions);
return $semaphore;
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"id",
",",
"int",
"$",
"maxLocks",
",",
"int",
"$",
"permissions",
"=",
"0600",
")",
":",
"self",
"{",
"if",
"(",
"$",
"maxLocks",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"Error",
"(",... | Creates a new semaphore with a given ID and number of locks.
@param string $id The unique name for the new semaphore.
@param int $maxLocks The maximum number of locks that can be acquired from the semaphore.
@param int $permissions Permissions to access the semaphore. Use file permission format specified as 0xxx.
@throws SyncException If the semaphore could not be created due to an internal error. | [
"Creates",
"a",
"new",
"semaphore",
"with",
"a",
"given",
"ID",
"and",
"number",
"of",
"locks",
"."
] | f91ee6ddc2b80848bd3906a6b0a8a442d9801093 | https://github.com/amphp/sync/blob/f91ee6ddc2b80848bd3906a6b0a8a442d9801093/lib/PosixSemaphore.php#L41-L49 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Exchange.php | Exchange.get | public function get($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s', urlencode($vhost), urlencode($name)));
} | php | public function get($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s', urlencode($vhost), urlencode($name)));
} | [
"public",
"function",
"get",
"(",
"$",
"vhost",
",",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/exchanges/%s/%s'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlencode",
"(",
"$",
"name"... | An individual exchange.
@param string $vhost
@param string $name
@return array | [
"An",
"individual",
"exchange",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Exchange.php#L40-L43 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Exchange.php | Exchange.sourceBindings | public function sourceBindings($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s/bindings/source', urlencode($vhost), urlencode($name)));
} | php | public function sourceBindings($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s/bindings/source', urlencode($vhost), urlencode($name)));
} | [
"public",
"function",
"sourceBindings",
"(",
"$",
"vhost",
",",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/exchanges/%s/%s/bindings/source'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
"urlenco... | A list of all bindings in which a given exchange is the source.
@param string $vhost
@param string $name
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"in",
"which",
"a",
"given",
"exchange",
"is",
"the",
"source",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Exchange.php#L92-L95 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Exchange.php | Exchange.destinationBindings | public function destinationBindings($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s/bindings/destination', urlencode($vhost), urlencode($name)));
} | php | public function destinationBindings($vhost, $name)
{
return $this->client->send(sprintf('/api/exchanges/%s/%s/bindings/destination', urlencode($vhost), urlencode($name)));
} | [
"public",
"function",
"destinationBindings",
"(",
"$",
"vhost",
",",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/exchanges/%s/%s/bindings/destination'",
",",
"urlencode",
"(",
"$",
"vhost",
")",
",",
... | A list of all bindings in which a given exchange is the destination.
@param string $vhost
@param string $name
@return array | [
"A",
"list",
"of",
"all",
"bindings",
"in",
"which",
"a",
"given",
"exchange",
"is",
"the",
"destination",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Exchange.php#L104-L107 | train |
richardfullmer/php-rabbitmq-management-api | src/Api/Node.php | Node.get | public function get($name, $memory = false)
{
return $this->client->send(sprintf('/api/nodes/%s%s', urlencode($name), $memory ? '?memory=true' : ''));
} | php | public function get($name, $memory = false)
{
return $this->client->send(sprintf('/api/nodes/%s%s', urlencode($name), $memory ? '?memory=true' : ''));
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"memory",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"sprintf",
"(",
"'/api/nodes/%s%s'",
",",
"urlencode",
"(",
"$",
"name",
")",
",",
"$",
"memory",
"?"... | An individual node in the RabbitMQ cluster. Add "?memory=true" to get memory statistics.
@param string $name
@param bool $memory
@return array | [
"An",
"individual",
"node",
"in",
"the",
"RabbitMQ",
"cluster",
".",
"Add",
"?memory",
"=",
"true",
"to",
"get",
"memory",
"statistics",
"."
] | 047383f9fc9dd0287e914f4a6f6c8ba9115e9aba | https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Node.php#L29-L32 | train |
amphp/sync | lib/Lock.php | Lock.release | public function release() {
if (!$this->releaser) {
return;
}
// Invoke the releaser function given to us by the synchronization source
// to release the lock.
$releaser = $this->releaser;
$this->releaser = null;
($releaser)($this);
} | php | public function release() {
if (!$this->releaser) {
return;
}
// Invoke the releaser function given to us by the synchronization source
// to release the lock.
$releaser = $this->releaser;
$this->releaser = null;
($releaser)($this);
} | [
"public",
"function",
"release",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"releaser",
")",
"{",
"return",
";",
"}",
"// Invoke the releaser function given to us by the synchronization source",
"// to release the lock.",
"$",
"releaser",
"=",
"$",
"this",
"-... | Releases the lock. No-op if the lock has already been released. | [
"Releases",
"the",
"lock",
".",
"No",
"-",
"op",
"if",
"the",
"lock",
"has",
"already",
"been",
"released",
"."
] | f91ee6ddc2b80848bd3906a6b0a8a442d9801093 | https://github.com/amphp/sync/blob/f91ee6ddc2b80848bd3906a6b0a8a442d9801093/lib/Lock.php#L50-L60 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php | ComponentPageUrlMatcher.matchComponent | protected function matchComponent(MatchUrlComponentAnnotation $annotation, $url)
{
$parser = new Parser($url);
return $this->matchByProperty($annotation, $parser, 'path')
&& $this->matchParams($annotation, $parser)
&& $this->matchSecure($annotation, $parser)
&& $this->matchByProperty($annotation, $parser, 'anchor', 'fragment')
&& $this->matchByProperty($annotation, $parser, 'host')
&& $this->matchByProperty($annotation, $parser, 'port')
&& $this->matchByProperty($annotation, $parser, 'user')
&& $this->matchByProperty($annotation, $parser, 'pass');
} | php | protected function matchComponent(MatchUrlComponentAnnotation $annotation, $url)
{
$parser = new Parser($url);
return $this->matchByProperty($annotation, $parser, 'path')
&& $this->matchParams($annotation, $parser)
&& $this->matchSecure($annotation, $parser)
&& $this->matchByProperty($annotation, $parser, 'anchor', 'fragment')
&& $this->matchByProperty($annotation, $parser, 'host')
&& $this->matchByProperty($annotation, $parser, 'port')
&& $this->matchByProperty($annotation, $parser, 'user')
&& $this->matchByProperty($annotation, $parser, 'pass');
} | [
"protected",
"function",
"matchComponent",
"(",
"MatchUrlComponentAnnotation",
"$",
"annotation",
",",
"$",
"url",
")",
"{",
"$",
"parser",
"=",
"new",
"Parser",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"matchByProperty",
"(",
"$",
"annotation... | Matches components to url.
@param MatchUrlComponentAnnotation $annotation The used annotation.
@param string $url The current url.
@return boolean | [
"Matches",
"components",
"to",
"url",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php#L82-L94 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php | ComponentPageUrlMatcher.matchParams | protected function matchParams(MatchUrlComponentAnnotation $annotation, Parser $parser)
{
// Not specified means match anything.
if ( !isset($annotation->params) ) {
return true;
}
return $parser->getParams() == $annotation->params;
} | php | protected function matchParams(MatchUrlComponentAnnotation $annotation, Parser $parser)
{
// Not specified means match anything.
if ( !isset($annotation->params) ) {
return true;
}
return $parser->getParams() == $annotation->params;
} | [
"protected",
"function",
"matchParams",
"(",
"MatchUrlComponentAnnotation",
"$",
"annotation",
",",
"Parser",
"$",
"parser",
")",
"{",
"// Not specified means match anything.",
"if",
"(",
"!",
"isset",
"(",
"$",
"annotation",
"->",
"params",
")",
")",
"{",
"return... | Matches query params.
@param MatchUrlComponentAnnotation $annotation The annotation.
@param Parser $parser Parser instance to match against.
@return boolean | [
"Matches",
"query",
"params",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php#L104-L112 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php | ComponentPageUrlMatcher.matchSecure | protected function matchSecure(MatchUrlComponentAnnotation $annotation, Parser $parser)
{
// Not specified means match anything.
if ( !isset($annotation->secure) ) {
return true;
}
return $parser->getComponent('scheme') === ($annotation->secure ? 'https' : 'http');
} | php | protected function matchSecure(MatchUrlComponentAnnotation $annotation, Parser $parser)
{
// Not specified means match anything.
if ( !isset($annotation->secure) ) {
return true;
}
return $parser->getComponent('scheme') === ($annotation->secure ? 'https' : 'http');
} | [
"protected",
"function",
"matchSecure",
"(",
"MatchUrlComponentAnnotation",
"$",
"annotation",
",",
"Parser",
"$",
"parser",
")",
"{",
"// Not specified means match anything.",
"if",
"(",
"!",
"isset",
"(",
"$",
"annotation",
"->",
"secure",
")",
")",
"{",
"return... | Matches secure option.
@param MatchUrlComponentAnnotation $annotation The annotation.
@param Parser $parser Parser instance to match against.
@return boolean | [
"Matches",
"secure",
"option",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php#L122-L130 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php | ComponentPageUrlMatcher.matchByProperty | protected function matchByProperty(
MatchUrlComponentAnnotation $annotation,
Parser $parser,
$property,
$component = null
) {
// Not specified means match anything.
if ( !isset($annotation->$property) ) {
return true;
}
return $parser->getComponent(isset($component) ? $component : $property) === $annotation->$property;
} | php | protected function matchByProperty(
MatchUrlComponentAnnotation $annotation,
Parser $parser,
$property,
$component = null
) {
// Not specified means match anything.
if ( !isset($annotation->$property) ) {
return true;
}
return $parser->getComponent(isset($component) ? $component : $property) === $annotation->$property;
} | [
"protected",
"function",
"matchByProperty",
"(",
"MatchUrlComponentAnnotation",
"$",
"annotation",
",",
"Parser",
"$",
"parser",
",",
"$",
"property",
",",
"$",
"component",
"=",
"null",
")",
"{",
"// Not specified means match anything.",
"if",
"(",
"!",
"isset",
... | Matches property.
@param MatchUrlComponentAnnotation $annotation The annotation.
@param Parser $parser Parser instance to match against.
@param string $property Property name.
@param string|null $component Component name.
@return boolean | [
"Matches",
"property",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageUrlMatcher/ComponentPageUrlMatcher.php#L142-L154 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/AbstractElementContainer.php | AbstractElementContainer.fromNodeElement | public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory)
{
$wrapped_element = WebElement::fromNodeElement($node_element, $page_factory);
return new static($wrapped_element, $page_factory);
} | php | public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory)
{
$wrapped_element = WebElement::fromNodeElement($node_element, $page_factory);
return new static($wrapped_element, $page_factory);
} | [
"public",
"static",
"function",
"fromNodeElement",
"(",
"NodeElement",
"$",
"node_element",
",",
"IPageFactory",
"$",
"page_factory",
")",
"{",
"$",
"wrapped_element",
"=",
"WebElement",
"::",
"fromNodeElement",
"(",
"$",
"node_element",
",",
"$",
"page_factory",
... | Creates Element instance based on existing NodeElement instance.
@param NodeElement $node_element Node element.
@param IPageFactory $page_factory Page factory.
@return static | [
"Creates",
"Element",
"instance",
"based",
"on",
"existing",
"NodeElement",
"instance",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/AbstractElementContainer.php#L50-L55 | train |
qa-tools/qa-tools | library/QATools/QATools/BEM/ElementLocator/BEMElementLocatorFactory.php | BEMElementLocatorFactory.createLocator | public function createLocator(Property $property)
{
return new BEMElementLocator($property, $this->searchContext, $this->annotationManager, $this->_locatorHelper);
} | php | public function createLocator(Property $property)
{
return new BEMElementLocator($property, $this->searchContext, $this->annotationManager, $this->_locatorHelper);
} | [
"public",
"function",
"createLocator",
"(",
"Property",
"$",
"property",
")",
"{",
"return",
"new",
"BEMElementLocator",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"searchContext",
",",
"$",
"this",
"->",
"annotationManager",
",",
"$",
"this",
"->",
"_loc... | When a field on a class needs to be decorated with an IElementLocator this method will be called.
@param Property $property Property.
@return IElementLocator | [
"When",
"a",
"field",
"on",
"a",
"class",
"needs",
"to",
"be",
"decorated",
"with",
"an",
"IElementLocator",
"this",
"method",
"will",
"be",
"called",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/BEM/ElementLocator/BEMElementLocatorFactory.php#L58-L61 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/Element/AbstractElementCollection.php | AbstractElementCollection.fromNodeElements | public static function fromNodeElements(
array $node_elements,
$element_class = null,
IPageFactory $page_factory
) {
$collection = new static();
if ( !isset($element_class) ) {
$element_class = $collection->elementClass;
}
if ( !$collection->isNodeElementAware($element_class) ) {
throw new ElementCollectionException(
sprintf('Collection element class "%s" must implement INodeElementAware interface', $element_class),
ElementCollectionException::TYPE_INCORRECT_ELEMENT_CLASS
);
}
foreach ( $node_elements as $node_element ) {
$collection[] = call_user_func(array($element_class, 'fromNodeElement'), $node_element, $page_factory);
}
return $collection;
} | php | public static function fromNodeElements(
array $node_elements,
$element_class = null,
IPageFactory $page_factory
) {
$collection = new static();
if ( !isset($element_class) ) {
$element_class = $collection->elementClass;
}
if ( !$collection->isNodeElementAware($element_class) ) {
throw new ElementCollectionException(
sprintf('Collection element class "%s" must implement INodeElementAware interface', $element_class),
ElementCollectionException::TYPE_INCORRECT_ELEMENT_CLASS
);
}
foreach ( $node_elements as $node_element ) {
$collection[] = call_user_func(array($element_class, 'fromNodeElement'), $node_element, $page_factory);
}
return $collection;
} | [
"public",
"static",
"function",
"fromNodeElements",
"(",
"array",
"$",
"node_elements",
",",
"$",
"element_class",
"=",
"null",
",",
"IPageFactory",
"$",
"page_factory",
")",
"{",
"$",
"collection",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"!",
"iss... | Creates new collection by wrapping given array of Node elements.
@param array|NodeElement[] $node_elements Node elements to wrap.
@param string $element_class Class name to wrap Node elements with.
@param IPageFactory $page_factory Page factory (optional) to use during wrapping.
@return static
@throws ElementCollectionException When element class used doesn't allow adding NodeElements inside. | [
"Creates",
"new",
"collection",
"by",
"wrapping",
"given",
"array",
"of",
"Node",
"elements",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/Element/AbstractElementCollection.php#L99-L122 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/Element/AbstractElementCollection.php | AbstractElementCollection.isNodeElementAware | protected function isNodeElementAware($class_name)
{
$node_element_aware_interface = 'QATools\\QATools\\PageObject\\Element\\INodeElementAware';
if ( class_exists($class_name) ) {
return in_array($node_element_aware_interface, class_implements($class_name));
}
return false;
} | php | protected function isNodeElementAware($class_name)
{
$node_element_aware_interface = 'QATools\\QATools\\PageObject\\Element\\INodeElementAware';
if ( class_exists($class_name) ) {
return in_array($node_element_aware_interface, class_implements($class_name));
}
return false;
} | [
"protected",
"function",
"isNodeElementAware",
"(",
"$",
"class_name",
")",
"{",
"$",
"node_element_aware_interface",
"=",
"'QATools\\\\QATools\\\\PageObject\\\\Element\\\\INodeElementAware'",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class_name",
")",
")",
"{",
"return"... | Determines if class is NodeElement aware.
@param string $class_name Class name.
@return boolean | [
"Determines",
"if",
"class",
"is",
"NodeElement",
"aware",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/Element/AbstractElementCollection.php#L131-L140 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/Element/AbstractElementCollection.php | AbstractElementCollection.assertElement | protected function assertElement($element)
{
if ( !is_a($element, $this->elementClass) ) {
$message = 'Collection element must be of "%s" class, but element of "%s" class given';
throw new ElementCollectionException(
sprintf($message, $this->elementClass, get_class($element)),
ElementCollectionException::TYPE_ELEMENT_CLASS_MISMATCH
);
}
return $this->acceptElement($element);
} | php | protected function assertElement($element)
{
if ( !is_a($element, $this->elementClass) ) {
$message = 'Collection element must be of "%s" class, but element of "%s" class given';
throw new ElementCollectionException(
sprintf($message, $this->elementClass, get_class($element)),
ElementCollectionException::TYPE_ELEMENT_CLASS_MISMATCH
);
}
return $this->acceptElement($element);
} | [
"protected",
"function",
"assertElement",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"elementClass",
")",
")",
"{",
"$",
"message",
"=",
"'Collection element must be of \"%s\" class, but element of \"%s\" cl... | Checks that element's class is allowed in collection.
@param mixed $element Element.
@return boolean
@throws ElementCollectionException When class of given element doesn't match one, that collection accepts. | [
"Checks",
"that",
"element",
"s",
"class",
"is",
"allowed",
"in",
"collection",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/Element/AbstractElementCollection.php#L150-L162 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/LabeledElement.php | LabeledElement.getLabel | public function getLabel()
{
$label = null;
$id = $this->getAttribute('id');
if ( !is_null($id) ) {
// Label with matching "for" attribute.
$escaped_id = $this->getXpathEscaper()->escapeLiteral($id);
$xpath_expressions = array(
'preceding::label[@for = ' . $escaped_id . ']',
'following::label[@for = ' . $escaped_id . ']',
);
$label = $this->getWrappedElement()->find('xpath', '(' . implode(' | ', $xpath_expressions) . ')[1]');
}
if ( is_null($label) ) {
// Label wrapped around checkbox.
$label = $this->getWrappedElement()->find('xpath', 'parent::label');
}
if ( is_null($label) ) {
// Label right next to checkbox.
$label = $this->getWrappedElement()->find('xpath', 'following-sibling::*[1][self::label]');
}
return $label;
} | php | public function getLabel()
{
$label = null;
$id = $this->getAttribute('id');
if ( !is_null($id) ) {
// Label with matching "for" attribute.
$escaped_id = $this->getXpathEscaper()->escapeLiteral($id);
$xpath_expressions = array(
'preceding::label[@for = ' . $escaped_id . ']',
'following::label[@for = ' . $escaped_id . ']',
);
$label = $this->getWrappedElement()->find('xpath', '(' . implode(' | ', $xpath_expressions) . ')[1]');
}
if ( is_null($label) ) {
// Label wrapped around checkbox.
$label = $this->getWrappedElement()->find('xpath', 'parent::label');
}
if ( is_null($label) ) {
// Label right next to checkbox.
$label = $this->getWrappedElement()->find('xpath', 'following-sibling::*[1][self::label]');
}
return $label;
} | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"$",
"label",
"=",
"null",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"{",
"// Label with matching \"for\" attribu... | Finds label corresponding to current element.
@return NodeElement|null Element representing label or null if no label has been found. | [
"Finds",
"label",
"corresponding",
"to",
"current",
"element",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/LabeledElement.php#L27-L53 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/Property.php | Property.getRawDataType | public function getRawDataType()
{
if ( !isset($this->dataType) ) {
/* @var $annotations VarAnnotation[] */
$annotations = $this->annotationManager->getPropertyAnnotations($this, null, '@var');
if ( $annotations && ($annotations[0] instanceof VarAnnotation) ) {
$this->dataType = $annotations[0]->type;
}
else {
$this->dataType = '';
}
}
return $this->dataType;
} | php | public function getRawDataType()
{
if ( !isset($this->dataType) ) {
/* @var $annotations VarAnnotation[] */
$annotations = $this->annotationManager->getPropertyAnnotations($this, null, '@var');
if ( $annotations && ($annotations[0] instanceof VarAnnotation) ) {
$this->dataType = $annotations[0]->type;
}
else {
$this->dataType = '';
}
}
return $this->dataType;
} | [
"public",
"function",
"getRawDataType",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dataType",
")",
")",
"{",
"/* @var $annotations VarAnnotation[] */",
"$",
"annotations",
"=",
"$",
"this",
"->",
"annotationManager",
"->",
"getPropertyAnnot... | Returns the raw data type.
@return string | [
"Returns",
"the",
"raw",
"data",
"type",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/Property.php#L74-L89 | train |
ikkez/f3-opauth | lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php | tmhUtilities.entify_with_options | public static function entify_with_options($tweet, $options=array(), &$replacements=array()) {
$default_opts = array(
'encoding' => 'UTF-8',
'target' => '',
);
$opts = array_merge($default_opts, $options);
$encoding = mb_internal_encoding();
mb_internal_encoding($opts['encoding']);
$keys = array();
$is_retweet = false;
if (isset($tweet['retweeted_status'])) {
$tweet = $tweet['retweeted_status'];
$is_retweet = true;
}
if (!isset($tweet['entities'])) {
return $tweet['text'];
}
$target = (!empty($opts['target'])) ? ' target="'.$opts['target'].'"' : '';
// prepare the entities
foreach ($tweet['entities'] as $type => $things) {
foreach ($things as $entity => $value) {
$tweet_link = "<a href=\"https://twitter.com/{$tweet['user']['screen_name']}/statuses/{$tweet['id']}\"{$target}>{$tweet['created_at']}</a>";
switch ($type) {
case 'hashtags':
$href = "<a href=\"https://twitter.com/search?q=%23{$value['text']}\"{$target}>#{$value['text']}</a>";
break;
case 'user_mentions':
$href = "@<a href=\"https://twitter.com/{$value['screen_name']}\" title=\"{$value['name']}\"{$target}>{$value['screen_name']}</a>";
break;
case 'urls':
case 'media':
$url = empty($value['expanded_url']) ? $value['url'] : $value['expanded_url'];
$display = isset($value['display_url']) ? $value['display_url'] : str_replace('http://', '', $url);
// Not all pages are served in UTF-8 so you may need to do this ...
$display = urldecode(str_replace('%E2%80%A6', '…', urlencode($display)));
$href = "<a href=\"{$value['url']}\"{$target}>{$display}</a>";
break;
}
$keys[$value['indices']['0']] = mb_substr(
$tweet['text'],
$value['indices']['0'],
$value['indices']['1'] - $value['indices']['0']
);
$replacements[$value['indices']['0']] = $href;
}
}
ksort($replacements);
$replacements = array_reverse($replacements, true);
$entified_tweet = $tweet['text'];
foreach ($replacements as $k => $v) {
$entified_tweet = mb_substr($entified_tweet, 0, $k).$v.mb_substr($entified_tweet, $k + strlen($keys[$k]));
}
$replacements = array(
'replacements' => $replacements,
'keys' => $keys
);
mb_internal_encoding($encoding);
return $entified_tweet;
} | php | public static function entify_with_options($tweet, $options=array(), &$replacements=array()) {
$default_opts = array(
'encoding' => 'UTF-8',
'target' => '',
);
$opts = array_merge($default_opts, $options);
$encoding = mb_internal_encoding();
mb_internal_encoding($opts['encoding']);
$keys = array();
$is_retweet = false;
if (isset($tweet['retweeted_status'])) {
$tweet = $tweet['retweeted_status'];
$is_retweet = true;
}
if (!isset($tweet['entities'])) {
return $tweet['text'];
}
$target = (!empty($opts['target'])) ? ' target="'.$opts['target'].'"' : '';
// prepare the entities
foreach ($tweet['entities'] as $type => $things) {
foreach ($things as $entity => $value) {
$tweet_link = "<a href=\"https://twitter.com/{$tweet['user']['screen_name']}/statuses/{$tweet['id']}\"{$target}>{$tweet['created_at']}</a>";
switch ($type) {
case 'hashtags':
$href = "<a href=\"https://twitter.com/search?q=%23{$value['text']}\"{$target}>#{$value['text']}</a>";
break;
case 'user_mentions':
$href = "@<a href=\"https://twitter.com/{$value['screen_name']}\" title=\"{$value['name']}\"{$target}>{$value['screen_name']}</a>";
break;
case 'urls':
case 'media':
$url = empty($value['expanded_url']) ? $value['url'] : $value['expanded_url'];
$display = isset($value['display_url']) ? $value['display_url'] : str_replace('http://', '', $url);
// Not all pages are served in UTF-8 so you may need to do this ...
$display = urldecode(str_replace('%E2%80%A6', '…', urlencode($display)));
$href = "<a href=\"{$value['url']}\"{$target}>{$display}</a>";
break;
}
$keys[$value['indices']['0']] = mb_substr(
$tweet['text'],
$value['indices']['0'],
$value['indices']['1'] - $value['indices']['0']
);
$replacements[$value['indices']['0']] = $href;
}
}
ksort($replacements);
$replacements = array_reverse($replacements, true);
$entified_tweet = $tweet['text'];
foreach ($replacements as $k => $v) {
$entified_tweet = mb_substr($entified_tweet, 0, $k).$v.mb_substr($entified_tweet, $k + strlen($keys[$k]));
}
$replacements = array(
'replacements' => $replacements,
'keys' => $keys
);
mb_internal_encoding($encoding);
return $entified_tweet;
} | [
"public",
"static",
"function",
"entify_with_options",
"(",
"$",
"tweet",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"&",
"$",
"replacements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"default_opts",
"=",
"array",
"(",
"'encoding'",
"=>",
"'UTF-8'",... | Entifies the tweet using the given entities element, using the provided
options.
@param array $tweet the json converted to normalised array
@param array $options settings to be used when rendering the entities
@param array $replacements if specified, the entities and their replacements will be stored to this variable
@return the tweet text with entities replaced with hyperlinks | [
"Entifies",
"the",
"tweet",
"using",
"the",
"given",
"entities",
"element",
"using",
"the",
"provided",
"options",
"."
] | 2f76ad82507202353de804a6885db8e58ccc6106 | https://github.com/ikkez/f3-opauth/blob/2f76ad82507202353de804a6885db8e58ccc6106/lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php#L36-L104 | train |
ikkez/f3-opauth | lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php | tmhUtilities.pr | public static function pr($obj) {
if (!self::is_cli())
echo '<pre style="word-wrap: break-word">';
if ( is_object($obj) )
print_r($obj);
elseif ( is_array($obj) )
print_r($obj);
else
echo $obj;
if (!self::is_cli())
echo '</pre>';
} | php | public static function pr($obj) {
if (!self::is_cli())
echo '<pre style="word-wrap: break-word">';
if ( is_object($obj) )
print_r($obj);
elseif ( is_array($obj) )
print_r($obj);
else
echo $obj;
if (!self::is_cli())
echo '</pre>';
} | [
"public",
"static",
"function",
"pr",
"(",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"is_cli",
"(",
")",
")",
"echo",
"'<pre style=\"word-wrap: break-word\">'",
";",
"if",
"(",
"is_object",
"(",
"$",
"obj",
")",
")",
"print_r",
"(",
"$",
"obj... | Debug function for printing the content of an object
@param mixes $obj | [
"Debug",
"function",
"for",
"printing",
"the",
"content",
"of",
"an",
"object"
] | 2f76ad82507202353de804a6885db8e58ccc6106 | https://github.com/ikkez/f3-opauth/blob/2f76ad82507202353de804a6885db8e58ccc6106/lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php#L156-L168 | train |
ikkez/f3-opauth | lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php | tmhUtilities.auto_fix_time_request | public static function auto_fix_time_request($tmhOAuth, $method, $url, $params=array(), $useauth=true, $multipart=false) {
$tmhOAuth->request($method, $url, $params, $useauth, $multipart);
// if we're not doing auth the timestamp isn't important
if ( ! $useauth)
return;
// some error that isn't a 401
if ($tmhOAuth->response['code'] != 401)
return;
// some error that is a 401 but isn't because the OAuth token and signature are incorrect
// TODO: this check is horrid but helps avoid requesting twice when the username and password are wrong
if (stripos($tmhOAuth->response['response'], 'password') !== false)
return;
// force the timestamp to be the same as the Twitter servers, and re-request
$tmhOAuth->auto_fixed_time = true;
$tmhOAuth->config['force_timestamp'] = true;
$tmhOAuth->config['timestamp'] = strtotime($tmhOAuth->response['headers']['date']);
return $tmhOAuth->request($method, $url, $params, $useauth, $multipart);
} | php | public static function auto_fix_time_request($tmhOAuth, $method, $url, $params=array(), $useauth=true, $multipart=false) {
$tmhOAuth->request($method, $url, $params, $useauth, $multipart);
// if we're not doing auth the timestamp isn't important
if ( ! $useauth)
return;
// some error that isn't a 401
if ($tmhOAuth->response['code'] != 401)
return;
// some error that is a 401 but isn't because the OAuth token and signature are incorrect
// TODO: this check is horrid but helps avoid requesting twice when the username and password are wrong
if (stripos($tmhOAuth->response['response'], 'password') !== false)
return;
// force the timestamp to be the same as the Twitter servers, and re-request
$tmhOAuth->auto_fixed_time = true;
$tmhOAuth->config['force_timestamp'] = true;
$tmhOAuth->config['timestamp'] = strtotime($tmhOAuth->response['headers']['date']);
return $tmhOAuth->request($method, $url, $params, $useauth, $multipart);
} | [
"public",
"static",
"function",
"auto_fix_time_request",
"(",
"$",
"tmhOAuth",
",",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"useauth",
"=",
"true",
",",
"$",
"multipart",
"=",
"false",
")",
"{",
"$",
"tmh... | Make an HTTP request using this library. This method is different to 'request'
because on a 401 error it will retry the request.
When a 401 error is returned it is possible the timestamp of the client is
too different to that of the API server. In this situation it is recommended
the request is retried with the OAuth timestamp set to the same as the API
server. This method will automatically try that technique.
This method doesn't return anything. Instead the response should be
inspected directly.
@param string $method the HTTP method being used. e.g. POST, GET, HEAD etc
@param string $url the request URL without query string parameters
@param array $params the request parameters as an array of key=value pairs
@param string $useauth whether to use authentication when making the request. Default true.
@param string $multipart whether this request contains multipart data. Default false | [
"Make",
"an",
"HTTP",
"request",
"using",
"this",
"library",
".",
"This",
"method",
"is",
"different",
"to",
"request",
"because",
"on",
"a",
"401",
"error",
"it",
"will",
"retry",
"the",
"request",
"."
] | 2f76ad82507202353de804a6885db8e58ccc6106 | https://github.com/ikkez/f3-opauth/blob/2f76ad82507202353de804a6885db8e58ccc6106/lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php#L188-L209 | train |
ikkez/f3-opauth | lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php | tmhUtilities.read_input | public static function read_input($prompt) {
echo $prompt;
$handle = fopen("php://stdin","r");
$data = fgets($handle);
return trim($data);
} | php | public static function read_input($prompt) {
echo $prompt;
$handle = fopen("php://stdin","r");
$data = fgets($handle);
return trim($data);
} | [
"public",
"static",
"function",
"read_input",
"(",
"$",
"prompt",
")",
"{",
"echo",
"$",
"prompt",
";",
"$",
"handle",
"=",
"fopen",
"(",
"\"php://stdin\"",
",",
"\"r\"",
")",
";",
"$",
"data",
"=",
"fgets",
"(",
"$",
"handle",
")",
";",
"return",
"t... | Asks the user for input and returns the line they enter
@param string $prompt the text to display to the user
@return the text entered by the user | [
"Asks",
"the",
"user",
"for",
"input",
"and",
"returns",
"the",
"line",
"they",
"enter"
] | 2f76ad82507202353de804a6885db8e58ccc6106 | https://github.com/ikkez/f3-opauth/blob/2f76ad82507202353de804a6885db8e58ccc6106/lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php#L217-L222 | train |
ikkez/f3-opauth | lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php | tmhUtilities.endswith | public static function endswith($haystack, $needle) {
$haylen = strlen($haystack);
$needlelen = strlen($needle);
if ($needlelen > $haylen)
return false;
return substr_compare($haystack, $needle, -$needlelen) === 0;
} | php | public static function endswith($haystack, $needle) {
$haylen = strlen($haystack);
$needlelen = strlen($needle);
if ($needlelen > $haylen)
return false;
return substr_compare($haystack, $needle, -$needlelen) === 0;
} | [
"public",
"static",
"function",
"endswith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"$",
"haylen",
"=",
"strlen",
"(",
"$",
"haystack",
")",
";",
"$",
"needlelen",
"=",
"strlen",
"(",
"$",
"needle",
")",
";",
"if",
"(",
"$",
"needlelen",
... | Check if one string ends with another
@param string $haystack the string to check inside of
@param string $needle the string to check $haystack ends with
@return true if $haystack ends with $needle, false otherwise | [
"Check",
"if",
"one",
"string",
"ends",
"with",
"another"
] | 2f76ad82507202353de804a6885db8e58ccc6106 | https://github.com/ikkez/f3-opauth/blob/2f76ad82507202353de804a6885db8e58ccc6106/lib/opauth/Strategy/Twitter/Vendor/tmhOAuth/tmhUtilities.php#L272-L279 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/FileInput.php | FileInput.setFileToUpload | public function setFileToUpload($filename)
{
if ( !file_exists($filename) ) {
throw new FileInputException(
'File "' . $filename . '" doesn\'t exist',
FileInputException::TYPE_FILE_NOT_FOUND
);
}
$this->getWrappedElement()->attachFile($filename);
return $this;
} | php | public function setFileToUpload($filename)
{
if ( !file_exists($filename) ) {
throw new FileInputException(
'File "' . $filename . '" doesn\'t exist',
FileInputException::TYPE_FILE_NOT_FOUND
);
}
$this->getWrappedElement()->attachFile($filename);
return $this;
} | [
"public",
"function",
"setFileToUpload",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"FileInputException",
"(",
"'File \"'",
".",
"$",
"filename",
".",
"'\" doesn\\'t exist'",
",",
"File... | Sets a file to be uploaded.
@param string $filename Filename.
@return self
@throws FileInputException When file could not be found on disk. | [
"Sets",
"a",
"file",
"to",
"be",
"uploaded",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/FileInput.php#L49-L61 | train |
qa-tools/qa-tools | library/QATools/QATools/BEM/Element/Block.php | Block.findAll | public function findAll($selector, $locator)
{
$items = array();
foreach ( $this->_nodes as $node ) {
$items = array_merge($items, $node->findAll($selector, $locator));
}
return $items;
} | php | public function findAll($selector, $locator)
{
$items = array();
foreach ( $this->_nodes as $node ) {
$items = array_merge($items, $node->findAll($selector, $locator));
}
return $items;
} | [
"public",
"function",
"findAll",
"(",
"$",
"selector",
",",
"$",
"locator",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_nodes",
"as",
"$",
"node",
")",
"{",
"$",
"items",
"=",
"array_merge",
"(",
"$",
... | Finds all elements with specified selector.
@param string $selector Selector engine name.
@param string|array $locator Selector locator.
@return NodeElement[] | [
"Finds",
"all",
"elements",
"with",
"specified",
"selector",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/BEM/Element/Block.php#L128-L137 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/AbstractTypifiedElement.php | AbstractTypifiedElement.assertWrappedElement | protected function assertWrappedElement()
{
if ( !$this->acceptanceCriteria ) {
return;
}
foreach ( $this->acceptanceCriteria as $criterion ) {
if ( !$this->isTagNameMatching($criterion) ) {
continue;
}
if ( $this->isAttributeMatching($criterion) ) {
return;
}
}
$message = 'Wrapped element "%s" does not match "%s" criteria';
throw new TypifiedElementException(
sprintf($message, $this->getWrappedElement(), get_class($this)),
TypifiedElementException::TYPE_INCORRECT_WRAPPED_ELEMENT
);
} | php | protected function assertWrappedElement()
{
if ( !$this->acceptanceCriteria ) {
return;
}
foreach ( $this->acceptanceCriteria as $criterion ) {
if ( !$this->isTagNameMatching($criterion) ) {
continue;
}
if ( $this->isAttributeMatching($criterion) ) {
return;
}
}
$message = 'Wrapped element "%s" does not match "%s" criteria';
throw new TypifiedElementException(
sprintf($message, $this->getWrappedElement(), get_class($this)),
TypifiedElementException::TYPE_INCORRECT_WRAPPED_ELEMENT
);
} | [
"protected",
"function",
"assertWrappedElement",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"acceptanceCriteria",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"acceptanceCriteria",
"as",
"$",
"criterion",
")",
"{",
"if",
"(",
"... | Checks that wrapped element meets the acceptance criteria.
@return void
@throws TypifiedElementException When no criteria matches. | [
"Checks",
"that",
"wrapped",
"element",
"meets",
"the",
"acceptance",
"criteria",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/AbstractTypifiedElement.php#L97-L119 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/AbstractTypifiedElement.php | AbstractTypifiedElement.isAttributeMatching | protected function isAttributeMatching(array $criterion)
{
if ( !isset($criterion[self::CRITERION_ATTRS]) ) {
return true;
}
foreach ( $criterion[self::CRITERION_ATTRS] as $attribute => $definition ) {
if ( $this->isValueMatchingCriterionDefinition($this->getAttribute($attribute), $definition) ) {
return true;
}
}
return false;
} | php | protected function isAttributeMatching(array $criterion)
{
if ( !isset($criterion[self::CRITERION_ATTRS]) ) {
return true;
}
foreach ( $criterion[self::CRITERION_ATTRS] as $attribute => $definition ) {
if ( $this->isValueMatchingCriterionDefinition($this->getAttribute($attribute), $definition) ) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isAttributeMatching",
"(",
"array",
"$",
"criterion",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"criterion",
"[",
"self",
"::",
"CRITERION_ATTRS",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"criterio... | Checks if the attributes of the criterion are matching.
@param array $criterion The criterion.
@return boolean | [
"Checks",
"if",
"the",
"attributes",
"of",
"the",
"criterion",
"are",
"matching",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/AbstractTypifiedElement.php#L144-L157 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory._createContainer | private function _createContainer(Config $config = null)
{
$container = new Container();
if ( isset($config) ) {
$container['config'] = $config;
}
return $container;
} | php | private function _createContainer(Config $config = null)
{
$container = new Container();
if ( isset($config) ) {
$container['config'] = $config;
}
return $container;
} | [
"private",
"function",
"_createContainer",
"(",
"Config",
"$",
"config",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
")",
")",
"{",
"$",
"container",
"[",
"'config'",
"]",
"... | Creates container_or_config object.
@param Config|null $config Config.
@return Container | [
"Creates",
"container_or_config",
"object",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L138-L147 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory._setAnnotationManager | private function _setAnnotationManager(AnnotationManager $manager)
{
foreach ( $this->annotationRegistry as $annotation_name => $annotation_class ) {
$manager->registry[$annotation_name] = $annotation_class;
}
$this->annotationManager = $manager;
return $this;
} | php | private function _setAnnotationManager(AnnotationManager $manager)
{
foreach ( $this->annotationRegistry as $annotation_name => $annotation_class ) {
$manager->registry[$annotation_name] = $annotation_class;
}
$this->annotationManager = $manager;
return $this;
} | [
"private",
"function",
"_setAnnotationManager",
"(",
"AnnotationManager",
"$",
"manager",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"annotationRegistry",
"as",
"$",
"annotation_name",
"=>",
"$",
"annotation_class",
")",
"{",
"$",
"manager",
"->",
"registry",
... | Sets annotation manager.
@param AnnotationManager $manager Annotation manager.
@return self | [
"Sets",
"annotation",
"manager",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L156-L165 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory._setSession | private function _setSession(Session $session)
{
$selectors_handler = $session->getSelectorsHandler();
if ( !$selectors_handler->isSelectorRegistered('se') ) {
$selectors_handler->registerSelector('se', new SeleniumSelector());
}
$this->_session = $session;
return $this;
} | php | private function _setSession(Session $session)
{
$selectors_handler = $session->getSelectorsHandler();
if ( !$selectors_handler->isSelectorRegistered('se') ) {
$selectors_handler->registerSelector('se', new SeleniumSelector());
}
$this->_session = $session;
return $this;
} | [
"private",
"function",
"_setSession",
"(",
"Session",
"$",
"session",
")",
"{",
"$",
"selectors_handler",
"=",
"$",
"session",
"->",
"getSelectorsHandler",
"(",
")",
";",
"if",
"(",
"!",
"$",
"selectors_handler",
"->",
"isSelectorRegistered",
"(",
"'se'",
")",... | Sets session.
@param Session $session Session.
@return self | [
"Sets",
"session",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L188-L199 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory.initPage | public function initPage(Page $page)
{
/* @var $annotations PageUrlAnnotation[] */
$annotations = $this->annotationManager->getClassAnnotations($page, '@page-url');
if ( !$annotations || !($annotations[0] instanceof PageUrlAnnotation) ) {
return $this;
}
$page->setUrlBuilder(
$this->urlFactory->getBuilder(
$this->urlNormalizer->normalize($annotations[0])
)
);
return $this;
} | php | public function initPage(Page $page)
{
/* @var $annotations PageUrlAnnotation[] */
$annotations = $this->annotationManager->getClassAnnotations($page, '@page-url');
if ( !$annotations || !($annotations[0] instanceof PageUrlAnnotation) ) {
return $this;
}
$page->setUrlBuilder(
$this->urlFactory->getBuilder(
$this->urlNormalizer->normalize($annotations[0])
)
);
return $this;
} | [
"public",
"function",
"initPage",
"(",
"Page",
"$",
"page",
")",
"{",
"/* @var $annotations PageUrlAnnotation[] */",
"$",
"annotations",
"=",
"$",
"this",
"->",
"annotationManager",
"->",
"getClassAnnotations",
"(",
"$",
"page",
",",
"'@page-url'",
")",
";",
"if",... | Initializes the page.
@param Page $page Page to initialize.
@return self | [
"Initializes",
"the",
"page",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L218-L234 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory.opened | public function opened(Page $page)
{
return $this->pageUrlMatcherRegistry->match($this->_session->getCurrentUrl(), $page);
} | php | public function opened(Page $page)
{
return $this->pageUrlMatcherRegistry->match($this->_session->getCurrentUrl(), $page);
} | [
"public",
"function",
"opened",
"(",
"Page",
"$",
"page",
")",
"{",
"return",
"$",
"this",
"->",
"pageUrlMatcherRegistry",
"->",
"match",
"(",
"$",
"this",
"->",
"_session",
"->",
"getCurrentUrl",
"(",
")",
",",
"$",
"page",
")",
";",
"}"
] | Checks if the given page is currently opened in browser.
@param Page $page Page to check.
@return boolean | [
"Checks",
"if",
"the",
"given",
"page",
"is",
"currently",
"opened",
"in",
"browser",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L243-L246 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory.proxyFields | protected function proxyFields(ISearchContext $search_context, IPropertyDecorator $property_decorator)
{
foreach ( $this->getProperties($search_context) as $property ) {
$proxy = $property_decorator->decorate($property);
if ( $proxy !== null ) {
$property->setAccessible(true);
$property->setValue($search_context, $proxy);
}
}
return $this;
} | php | protected function proxyFields(ISearchContext $search_context, IPropertyDecorator $property_decorator)
{
foreach ( $this->getProperties($search_context) as $property ) {
$proxy = $property_decorator->decorate($property);
if ( $proxy !== null ) {
$property->setAccessible(true);
$property->setValue($search_context, $proxy);
}
}
return $this;
} | [
"protected",
"function",
"proxyFields",
"(",
"ISearchContext",
"$",
"search_context",
",",
"IPropertyDecorator",
"$",
"property_decorator",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getProperties",
"(",
"$",
"search_context",
")",
"as",
"$",
"property",
")",
... | Initializes fields within given search context.
@param ISearchContext $search_context Search context.
@param IPropertyDecorator $property_decorator Property decorator.
@return self | [
"Initializes",
"fields",
"within",
"given",
"search",
"context",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L281-L293 | train |
qa-tools/qa-tools | library/QATools/QATools/PageObject/PageFactory.php | PageFactory.getProperties | protected function getProperties(ISearchContext $search_context)
{
$ret = array();
$reflection = new \ReflectionClass($search_context);
foreach ( $reflection->getProperties() as $property ) {
$ret[] = new Property($property, $this->annotationManager);
}
return $ret;
} | php | protected function getProperties(ISearchContext $search_context)
{
$ret = array();
$reflection = new \ReflectionClass($search_context);
foreach ( $reflection->getProperties() as $property ) {
$ret[] = new Property($property, $this->annotationManager);
}
return $ret;
} | [
"protected",
"function",
"getProperties",
"(",
"ISearchContext",
"$",
"search_context",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"search_context",
")",
";",
"foreach",
"(",
"$",
"r... | Returns class properties, that can potentially become proxies.
@param ISearchContext $search_context Search context.
@return Property[] | [
"Returns",
"class",
"properties",
"that",
"can",
"potentially",
"become",
"proxies",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/PageObject/PageFactory.php#L302-L312 | train |
qa-tools/qa-tools | library/QATools/QATools/HtmlElements/Element/Form.php | Form.fill | public function fill(array $form_data)
{
foreach ( $form_data as $field_name => $field_value ) {
$form_element = $this->typify($this->getNodeElements($field_name));
$this->setValue($form_element, $field_value);
}
return $this;
} | php | public function fill(array $form_data)
{
foreach ( $form_data as $field_name => $field_value ) {
$form_element = $this->typify($this->getNodeElements($field_name));
$this->setValue($form_element, $field_value);
}
return $this;
} | [
"public",
"function",
"fill",
"(",
"array",
"$",
"form_data",
")",
"{",
"foreach",
"(",
"$",
"form_data",
"as",
"$",
"field_name",
"=>",
"$",
"field_value",
")",
"{",
"$",
"form_element",
"=",
"$",
"this",
"->",
"typify",
"(",
"$",
"this",
"->",
"getNo... | Fills the form with given data.
@param array $form_data Associative array with keys matching field names.
@return self | [
"Fills",
"the",
"form",
"with",
"given",
"data",
"."
] | deebf0113190dd85129e20afa0c42b8afe9cb8d6 | https://github.com/qa-tools/qa-tools/blob/deebf0113190dd85129e20afa0c42b8afe9cb8d6/library/QATools/QATools/HtmlElements/Element/Form.php#L41-L50 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.