id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
2,500
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.pull
public function pull($key) { $value = $this->get($key); $this->remove($key); return $value; }
php
public function pull($key) { $value = $this->get($key); $this->remove($key); return $value; }
[ "public", "function", "pull", "(", "$", "key", ")", "{", "$", "value", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "$", "this", "->", "remove", "(", "$", "key", ")", ";", "return", "$", "value", ";", "}" ]
Retrieves and removes a value @param mixed $key The key @return mixed
[ "Retrieves", "and", "removes", "a", "value" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L267-L273
2,501
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.splice
public function splice(int $offset, ?int $length = null, array $replacement = []): ArrayCollection { if ($length === null && empty($replacement)) { return new static(array_splice($this->items, $offset)); } if ($length === null) { $length = $this->count(); } return new static(array_splice($this->items, $offset, $length, $replacement)); }
php
public function splice(int $offset, ?int $length = null, array $replacement = []): ArrayCollection { if ($length === null && empty($replacement)) { return new static(array_splice($this->items, $offset)); } if ($length === null) { $length = $this->count(); } return new static(array_splice($this->items, $offset, $length, $replacement)); }
[ "public", "function", "splice", "(", "int", "$", "offset", ",", "?", "int", "$", "length", "=", "null", ",", "array", "$", "replacement", "=", "[", "]", ")", ":", "ArrayCollection", "{", "if", "(", "$", "length", "===", "null", "&&", "empty", "(", "$", "replacement", ")", ")", "{", "return", "new", "static", "(", "array_splice", "(", "$", "this", "->", "items", ",", "$", "offset", ")", ")", ";", "}", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "$", "this", "->", "count", "(", ")", ";", "}", "return", "new", "static", "(", "array_splice", "(", "$", "this", "->", "items", ",", "$", "offset", ",", "$", "length", ",", "$", "replacement", ")", ")", ";", "}" ]
Removes and returns a portion of the collection Replacement items will replace removed items in the collection. @param int $offset The starting offset @param int|null $length The length or null for remaining @param array $replacement The replacement items @return ArrayCollection
[ "Removes", "and", "returns", "a", "portion", "of", "the", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L318-L329
2,502
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.contains
public function contains($value, bool $strict = true): bool { return in_array($value, $this->items, $strict); }
php
public function contains($value, bool $strict = true): bool { return in_array($value, $this->items, $strict); }
[ "public", "function", "contains", "(", "$", "value", ",", "bool", "$", "strict", "=", "true", ")", ":", "bool", "{", "return", "in_array", "(", "$", "value", ",", "$", "this", "->", "items", ",", "$", "strict", ")", ";", "}" ]
Checks if a value exists @param mixed $value The value @param bool $strict Whether comparison should be strict @return bool
[ "Checks", "if", "a", "value", "exists" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L339-L342
2,503
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.search
public function search($value, bool $strict = true) { return array_search($value, $this->items, $strict); }
php
public function search($value, bool $strict = true) { return array_search($value, $this->items, $strict); }
[ "public", "function", "search", "(", "$", "value", ",", "bool", "$", "strict", "=", "true", ")", "{", "return", "array_search", "(", "$", "value", ",", "$", "this", "->", "items", ",", "$", "strict", ")", ";", "}" ]
Retrieves the key for a given value Returns FALSE if the value is not found. @param mixed $value The value @param bool $strict Whether comparison should be strict @return mixed
[ "Retrieves", "the", "key", "for", "a", "given", "value" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L354-L357
2,504
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.any
public function any(callable $predicate): bool { foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { return true; } } return false; }
php
public function any(callable $predicate): bool { foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { return true; } } return false; }
[ "public", "function", "any", "(", "callable", "$", "predicate", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if any items pass a truth test Predicate signature: <code> function ($value, $key): bool {} </code> @param callable $predicate The predicate function @return bool
[ "Checks", "if", "any", "items", "pass", "a", "truth", "test" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L412-L421
2,505
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.first
public function first(?callable $predicate = null, $default = null) { if ($predicate === null) { return $this->isEmpty() ? $default : reset($this->items); } foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { return $value; } } return $default; }
php
public function first(?callable $predicate = null, $default = null) { if ($predicate === null) { return $this->isEmpty() ? $default : reset($this->items); } foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { return $value; } } return $default; }
[ "public", "function", "first", "(", "?", "callable", "$", "predicate", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "predicate", "===", "null", ")", "{", "return", "$", "this", "->", "isEmpty", "(", ")", "?", "$", "default", ":", "reset", "(", "$", "this", "->", "items", ")", ";", "}", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "$", "default", ";", "}" ]
Retrieves the first value from the collection Optionally retrieves the first value that passes a truth test. Predicate signature: <code> function ($value, $key): bool {} </code> @param callable|null $predicate The predicate function @param mixed $default The default return value @return mixed
[ "Retrieves", "the", "first", "value", "from", "the", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L463-L476
2,506
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.last
public function last(?callable $predicate = null, $default = null) { if ($predicate === null) { return $this->isEmpty() ? $default : end($this->items); } foreach (array_reverse($this->items, true) as $key => $value) { if ($predicate($value, $key)) { return $value; } } return $default; }
php
public function last(?callable $predicate = null, $default = null) { if ($predicate === null) { return $this->isEmpty() ? $default : end($this->items); } foreach (array_reverse($this->items, true) as $key => $value) { if ($predicate($value, $key)) { return $value; } } return $default; }
[ "public", "function", "last", "(", "?", "callable", "$", "predicate", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "predicate", "===", "null", ")", "{", "return", "$", "this", "->", "isEmpty", "(", ")", "?", "$", "default", ":", "end", "(", "$", "this", "->", "items", ")", ";", "}", "foreach", "(", "array_reverse", "(", "$", "this", "->", "items", ",", "true", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "$", "default", ";", "}" ]
Retrieves the last value from the collection Optionally retrieves the last value that passes a truth test. Predicate signature: <code> function ($value, $key): bool {} </code> @param callable|null $predicate The predicate function @param mixed $default The default return value @return mixed
[ "Retrieves", "the", "last", "value", "from", "the", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L494-L507
2,507
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.random
public function random(int $amount = 1) { $count = $this->count(); if ($amount > $count) { $message = sprintf('Requested %d items with %d items present', $amount, $count); throw new DomainException($message); } $keys = array_rand($this->items, $amount); if ($amount === 1) { return $this->items[$keys]; } return new static(array_intersect_key($this->items, array_flip($keys))); }
php
public function random(int $amount = 1) { $count = $this->count(); if ($amount > $count) { $message = sprintf('Requested %d items with %d items present', $amount, $count); throw new DomainException($message); } $keys = array_rand($this->items, $amount); if ($amount === 1) { return $this->items[$keys]; } return new static(array_intersect_key($this->items, array_flip($keys))); }
[ "public", "function", "random", "(", "int", "$", "amount", "=", "1", ")", "{", "$", "count", "=", "$", "this", "->", "count", "(", ")", ";", "if", "(", "$", "amount", ">", "$", "count", ")", "{", "$", "message", "=", "sprintf", "(", "'Requested %d items with %d items present'", ",", "$", "amount", ",", "$", "count", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "$", "keys", "=", "array_rand", "(", "$", "this", "->", "items", ",", "$", "amount", ")", ";", "if", "(", "$", "amount", "===", "1", ")", "{", "return", "$", "this", "->", "items", "[", "$", "keys", "]", ";", "}", "return", "new", "static", "(", "array_intersect_key", "(", "$", "this", "->", "items", ",", "array_flip", "(", "$", "keys", ")", ")", ")", ";", "}" ]
Retrieves items randomly @param int $amount The number of items @return mixed @throws DomainException When amount is greater than item count
[ "Retrieves", "items", "randomly" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L518-L533
2,508
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.sort
public function sort(callable $comparator = null): ArrayCollection { $items = $this->items; $comparator ? uasort($items, $comparator) : uasort($items, function ($a, $b) { return $a <=> $b; }); return new static($items); }
php
public function sort(callable $comparator = null): ArrayCollection { $items = $this->items; $comparator ? uasort($items, $comparator) : uasort($items, function ($a, $b) { return $a <=> $b; }); return new static($items); }
[ "public", "function", "sort", "(", "callable", "$", "comparator", "=", "null", ")", ":", "ArrayCollection", "{", "$", "items", "=", "$", "this", "->", "items", ";", "$", "comparator", "?", "uasort", "(", "$", "items", ",", "$", "comparator", ")", ":", "uasort", "(", "$", "items", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "<=>", "$", "b", ";", "}", ")", ";", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a sorted collection Comparator signature: <code> function ($a, $b): int {} </code> @param callable|null $comparator The comparator function @return ArrayCollection
[ "Creates", "a", "sorted", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L574-L583
2,509
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.sortBy
public function sortBy(callable $callback, $options = SORT_REGULAR, $descending = false): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$key] = $callback($value, $key); } if ($descending) { arsort($items, $options); } else { asort($items, $options); } foreach (array_keys($items) as $key) { $items[$key] = $this->items[$key]; } return new static($items); }
php
public function sortBy(callable $callback, $options = SORT_REGULAR, $descending = false): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$key] = $callback($value, $key); } if ($descending) { arsort($items, $options); } else { asort($items, $options); } foreach (array_keys($items) as $key) { $items[$key] = $this->items[$key]; } return new static($items); }
[ "public", "function", "sortBy", "(", "callable", "$", "callback", ",", "$", "options", "=", "SORT_REGULAR", ",", "$", "descending", "=", "false", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", "if", "(", "$", "descending", ")", "{", "arsort", "(", "$", "items", ",", "$", "options", ")", ";", "}", "else", "{", "asort", "(", "$", "items", ",", "$", "options", ")", ";", "}", "foreach", "(", "array_keys", "(", "$", "items", ")", "as", "$", "key", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a sorted collection using values from a callback Callback function should return a value for comparison Callback signature: <code> function ($value, $key): mixed {} </code> @param callable $callback The callback function @param int $options The sort options @param bool $descending Whether to sort in descending order @return ArrayCollection
[ "Creates", "a", "sorted", "collection", "using", "values", "from", "a", "callback" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L602-L621
2,510
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.sortByDesc
public function sortByDesc(callable $callback, $options = SORT_REGULAR): ArrayCollection { return $this->sortBy($callback, $options, true); }
php
public function sortByDesc(callable $callback, $options = SORT_REGULAR): ArrayCollection { return $this->sortBy($callback, $options, true); }
[ "public", "function", "sortByDesc", "(", "callable", "$", "callback", ",", "$", "options", "=", "SORT_REGULAR", ")", ":", "ArrayCollection", "{", "return", "$", "this", "->", "sortBy", "(", "$", "callback", ",", "$", "options", ",", "true", ")", ";", "}" ]
Creates a descending sorted collection using values from a callback Callback function should return a value for comparison Callback signature: <code> function ($value, $key): mixed {} </code> @param callable $callback The callback function @param int $options The sort options @return ArrayCollection
[ "Creates", "a", "descending", "sorted", "collection", "using", "values", "from", "a", "callback" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L639-L642
2,511
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.each
public function each(callable $callback): ArrayCollection { foreach ($this->items as $key => $value) { $callback($value, $key); } return $this; }
php
public function each(callable $callback): ArrayCollection { foreach ($this->items as $key => $value) { $callback($value, $key); } return $this; }
[ "public", "function", "each", "(", "callable", "$", "callback", ")", ":", "ArrayCollection", "{", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", "return", "$", "this", ";", "}" ]
Applies a callback function to every item Callback signature: <code> function ($value, $key): void {} </code> @param callable $callback The callback function @return ArrayCollection
[ "Applies", "a", "callback", "function", "to", "every", "item" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L675-L682
2,512
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.map
public function map(callable $callback): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$key] = $callback($value, $key); } return new static($items); }
php
public function map(callable $callback): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$key] = $callback($value, $key); } return new static($items); }
[ "public", "function", "map", "(", "callable", "$", "callback", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection from the results of a callback function Callback signature: <code> function ($value, $key): mixed {} </code> @param callable $callback The callback function @return ArrayCollection
[ "Creates", "a", "collection", "from", "the", "results", "of", "a", "callback", "function" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L697-L706
2,513
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.pluck
public function pluck(string $key): ArrayCollection { return $this->map(function ($value) use ($key) { return $value[$key] ?? null; }); }
php
public function pluck(string $key): ArrayCollection { return $this->map(function ($value) use ($key) { return $value[$key] ?? null; }); }
[ "public", "function", "pluck", "(", "string", "$", "key", ")", ":", "ArrayCollection", "{", "return", "$", "this", "->", "map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "key", ")", "{", "return", "$", "value", "[", "$", "key", "]", "??", "null", ";", "}", ")", ";", "}" ]
Creates a collection of values with a given key @param string $key The key @return ArrayCollection
[ "Creates", "a", "collection", "of", "values", "with", "a", "given", "key" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L715-L720
2,514
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.keyBy
public function keyBy(callable $callback): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$callback($value, $key)] = $value; } return new static($items); }
php
public function keyBy(callable $callback): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $items[$callback($value, $key)] = $value; } return new static($items); }
[ "public", "function", "keyBy", "(", "callable", "$", "callback", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "items", "[", "$", "callback", "(", "$", "value", ",", "$", "key", ")", "]", "=", "$", "value", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection keyed by keys from a callback Callback signature: <code> function ($value, $key): mixed {} </code> @param callable $callback The callback function @return ArrayCollection
[ "Creates", "a", "collection", "keyed", "by", "keys", "from", "a", "callback" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L735-L744
2,515
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.groupBy
public function groupBy(callable $callback, bool $preserveKeys = false): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $group = $callback($value, $key); if (!array_key_exists($group, $items)) { $items[$group] = new static(); } $items[$group]->set($preserveKeys ? $key : null, $value); } return new static($items); }
php
public function groupBy(callable $callback, bool $preserveKeys = false): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { $group = $callback($value, $key); if (!array_key_exists($group, $items)) { $items[$group] = new static(); } $items[$group]->set($preserveKeys ? $key : null, $value); } return new static($items); }
[ "public", "function", "groupBy", "(", "callable", "$", "callback", ",", "bool", "$", "preserveKeys", "=", "false", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "group", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "group", ",", "$", "items", ")", ")", "{", "$", "items", "[", "$", "group", "]", "=", "new", "static", "(", ")", ";", "}", "$", "items", "[", "$", "group", "]", "->", "set", "(", "$", "preserveKeys", "?", "$", "key", ":", "null", ",", "$", "value", ")", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection grouped by keys from a callback Callback signature: <code> function ($value, $key): mixed {} </code> @param callable $callback The callback function @param bool $preserveKeys Whether to preserve keys @return ArrayCollection
[ "Creates", "a", "collection", "grouped", "by", "keys", "from", "a", "callback" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L760-L775
2,516
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.chunk
public function chunk(int $size, bool $preserveKeys = false): ArrayCollection { $chunks = []; foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) { $chunks[] = new static($chunk); } return new static($chunks); }
php
public function chunk(int $size, bool $preserveKeys = false): ArrayCollection { $chunks = []; foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) { $chunks[] = new static($chunk); } return new static($chunks); }
[ "public", "function", "chunk", "(", "int", "$", "size", ",", "bool", "$", "preserveKeys", "=", "false", ")", ":", "ArrayCollection", "{", "$", "chunks", "=", "[", "]", ";", "foreach", "(", "array_chunk", "(", "$", "this", "->", "items", ",", "$", "size", ",", "$", "preserveKeys", ")", "as", "$", "chunk", ")", "{", "$", "chunks", "[", "]", "=", "new", "static", "(", "$", "chunk", ")", ";", "}", "return", "new", "static", "(", "$", "chunks", ")", ";", "}" ]
Creates a collection with item chunks @param int $size The chunk size @param bool $preserveKeys Whether to preserve keys @return ArrayCollection
[ "Creates", "a", "collection", "with", "item", "chunks" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L799-L808
2,517
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.collapse
public function collapse(): ArrayCollection { $items = []; foreach ($this->items as $values) { if ($values instanceof self) { $values = $values->all(); } elseif (!is_array($values)) { continue; } $items = array_merge($items, $values); } return new static($items); }
php
public function collapse(): ArrayCollection { $items = []; foreach ($this->items as $values) { if ($values instanceof self) { $values = $values->all(); } elseif (!is_array($values)) { continue; } $items = array_merge($items, $values); } return new static($items); }
[ "public", "function", "collapse", "(", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "values", ")", "{", "if", "(", "$", "values", "instanceof", "self", ")", "{", "$", "values", "=", "$", "values", "->", "all", "(", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "continue", ";", "}", "$", "items", "=", "array_merge", "(", "$", "items", ",", "$", "values", ")", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection with items collapsed @return ArrayCollection
[ "Creates", "a", "collection", "with", "items", "collapsed" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L845-L859
2,518
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.zip
public function zip(...$items): ArrayCollection { $arrayItems = array_map(function ($items) { return $this->itemsArray($items); }, $items); $params = array_merge([function (...$items) { return new static($items); }, $this->items], $arrayItems); return new static(call_user_func_array('array_map', $params)); }
php
public function zip(...$items): ArrayCollection { $arrayItems = array_map(function ($items) { return $this->itemsArray($items); }, $items); $params = array_merge([function (...$items) { return new static($items); }, $this->items], $arrayItems); return new static(call_user_func_array('array_map', $params)); }
[ "public", "function", "zip", "(", "...", "$", "items", ")", ":", "ArrayCollection", "{", "$", "arrayItems", "=", "array_map", "(", "function", "(", "$", "items", ")", "{", "return", "$", "this", "->", "itemsArray", "(", "$", "items", ")", ";", "}", ",", "$", "items", ")", ";", "$", "params", "=", "array_merge", "(", "[", "function", "(", "...", "$", "items", ")", "{", "return", "new", "static", "(", "$", "items", ")", ";", "}", ",", "$", "this", "->", "items", "]", ",", "$", "arrayItems", ")", ";", "return", "new", "static", "(", "call_user_func_array", "(", "'array_map'", ",", "$", "params", ")", ")", ";", "}" ]
Creates a collection zipped with the given items @param mixed ...$items The items @return ArrayCollection
[ "Creates", "a", "collection", "zipped", "with", "the", "given", "items" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L890-L901
2,519
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.unique
public function unique(?callable $callback = null): ArrayCollection { if ($callback === null) { return new static(array_unique($this->items, SORT_REGULAR)); } $set = []; return $this->filter(function ($value, $key) use ($callback, &$set) { $hash = $callback($value, $key); if (isset($set[$hash])) { return false; } $set[$hash] = true; return true; }); }
php
public function unique(?callable $callback = null): ArrayCollection { if ($callback === null) { return new static(array_unique($this->items, SORT_REGULAR)); } $set = []; return $this->filter(function ($value, $key) use ($callback, &$set) { $hash = $callback($value, $key); if (isset($set[$hash])) { return false; } $set[$hash] = true; return true; }); }
[ "public", "function", "unique", "(", "?", "callable", "$", "callback", "=", "null", ")", ":", "ArrayCollection", "{", "if", "(", "$", "callback", "===", "null", ")", "{", "return", "new", "static", "(", "array_unique", "(", "$", "this", "->", "items", ",", "SORT_REGULAR", ")", ")", ";", "}", "$", "set", "=", "[", "]", ";", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ",", "&", "$", "set", ")", "{", "$", "hash", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "set", "[", "$", "hash", "]", ")", ")", "{", "return", "false", ";", "}", "$", "set", "[", "$", "hash", "]", "=", "true", ";", "return", "true", ";", "}", ")", ";", "}" ]
Creates a collection with unique items Optional callback should return a string value for equality comparison. Callback signature: <code> function ($value, $key): string {} </code> @param callable|null $callback The callback function @return ArrayCollection
[ "Creates", "a", "collection", "with", "unique", "items" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L918-L934
2,520
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.union
public function union($items): ArrayCollection { return new static(array_unique(array_merge($this->items, $this->itemsArray($items)))); }
php
public function union($items): ArrayCollection { return new static(array_unique(array_merge($this->items, $this->itemsArray($items)))); }
[ "public", "function", "union", "(", "$", "items", ")", ":", "ArrayCollection", "{", "return", "new", "static", "(", "array_unique", "(", "array_merge", "(", "$", "this", "->", "items", ",", "$", "this", "->", "itemsArray", "(", "$", "items", ")", ")", ")", ")", ";", "}" ]
Creates a collection with the union of current and given items @param mixed $items The items @return ArrayCollection
[ "Creates", "a", "collection", "with", "the", "union", "of", "current", "and", "given", "items" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L979-L982
2,521
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.filter
public function filter(callable $predicate): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { $items[$key] = $value; } } return new static($items); }
php
public function filter(callable $predicate): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { $items[$key] = $value; } } return new static($items); }
[ "public", "function", "filter", "(", "callable", "$", "predicate", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection from items that pass a truth test Predicate signature: <code> function ($value, $key): bool {} </code> @param callable $predicate The predicate function @return ArrayCollection
[ "Creates", "a", "collection", "from", "items", "that", "pass", "a", "truth", "test" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1009-L1020
2,522
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.reject
public function reject(callable $predicate): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { if (!$predicate($value, $key)) { $items[$key] = $value; } } return new static($items); }
php
public function reject(callable $predicate): ArrayCollection { $items = []; foreach ($this->items as $key => $value) { if (!$predicate($value, $key)) { $items[$key] = $value; } } return new static($items); }
[ "public", "function", "reject", "(", "callable", "$", "predicate", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection from items that fail a truth test Predicate signature: <code> function ($value, $key): bool {} </code> @param callable $predicate The predicate function @return ArrayCollection
[ "Creates", "a", "collection", "from", "items", "that", "fail", "a", "truth", "test" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1035-L1046
2,523
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.where
public function where($key, $value, bool $strict = true): ArrayCollection { return $this->filter(function ($item) use ($key, $value, $strict) { if (!isset($item[$key])) { return false; } return $strict ? $item[$key] === $value : $item[$key] == $value; }); }
php
public function where($key, $value, bool $strict = true): ArrayCollection { return $this->filter(function ($item) use ($key, $value, $strict) { if (!isset($item[$key])) { return false; } return $strict ? $item[$key] === $value : $item[$key] == $value; }); }
[ "public", "function", "where", "(", "$", "key", ",", "$", "value", ",", "bool", "$", "strict", "=", "true", ")", ":", "ArrayCollection", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "item", ")", "use", "(", "$", "key", ",", "$", "value", ",", "$", "strict", ")", "{", "if", "(", "!", "isset", "(", "$", "item", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "strict", "?", "$", "item", "[", "$", "key", "]", "===", "$", "value", ":", "$", "item", "[", "$", "key", "]", "==", "$", "value", ";", "}", ")", ";", "}" ]
Creates a filtered collection by key and value @param mixed $key The key @param mixed $value The value @param bool $strict Whether comparison should be strict @return ArrayCollection
[ "Creates", "a", "filtered", "collection", "by", "key", "and", "value" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1057-L1066
2,524
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.whereIn
public function whereIn($key, array $values, bool $strict = true): ArrayCollection { return $this->filter(function ($item) use ($key, $values, $strict) { if (!isset($item[$key])) { return false; } return in_array($item[$key], $values, $strict); }); }
php
public function whereIn($key, array $values, bool $strict = true): ArrayCollection { return $this->filter(function ($item) use ($key, $values, $strict) { if (!isset($item[$key])) { return false; } return in_array($item[$key], $values, $strict); }); }
[ "public", "function", "whereIn", "(", "$", "key", ",", "array", "$", "values", ",", "bool", "$", "strict", "=", "true", ")", ":", "ArrayCollection", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "item", ")", "use", "(", "$", "key", ",", "$", "values", ",", "$", "strict", ")", "{", "if", "(", "!", "isset", "(", "$", "item", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "return", "in_array", "(", "$", "item", "[", "$", "key", "]", ",", "$", "values", ",", "$", "strict", ")", ";", "}", ")", ";", "}" ]
Creates a filtered collection by key and values @param mixed $key The key @param array $values The values @param bool $strict Whether comparison should be strict @return ArrayCollection
[ "Creates", "a", "filtered", "collection", "by", "key", "and", "values" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1077-L1086
2,525
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.slice
public function slice(int $offset, ?int $length = null): ArrayCollection { return new static(array_slice($this->items, $offset, $length, true)); }
php
public function slice(int $offset, ?int $length = null): ArrayCollection { return new static(array_slice($this->items, $offset, $length, true)); }
[ "public", "function", "slice", "(", "int", "$", "offset", ",", "?", "int", "$", "length", "=", "null", ")", ":", "ArrayCollection", "{", "return", "new", "static", "(", "array_slice", "(", "$", "this", "->", "items", ",", "$", "offset", ",", "$", "length", ",", "true", ")", ")", ";", "}" ]
Creates a collection from a slice of items @param int $offset The starting offset @param int|null $length The length or null for remaining @return ArrayCollection
[ "Creates", "a", "collection", "from", "a", "slice", "of", "items" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1096-L1099
2,526
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.skip
public function skip(int $step): ArrayCollection { $items = []; $pos = 0; foreach ($this->items as $key => $value) { if ($pos % $step === 0) { $items[$key] = $value; } $pos++; } return new static($items); }
php
public function skip(int $step): ArrayCollection { $items = []; $pos = 0; foreach ($this->items as $key => $value) { if ($pos % $step === 0) { $items[$key] = $value; } $pos++; } return new static($items); }
[ "public", "function", "skip", "(", "int", "$", "step", ")", ":", "ArrayCollection", "{", "$", "items", "=", "[", "]", ";", "$", "pos", "=", "0", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "pos", "%", "$", "step", "===", "0", ")", "{", "$", "items", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "pos", "++", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Creates a collection with every n-th element @param int $step The step number @return ArrayCollection
[ "Creates", "a", "collection", "with", "every", "n", "-", "th", "element" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1126-L1139
2,527
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.partition
public function partition(callable $predicate): ArrayCollection { $items1 = []; $items2 = []; foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { $items1[$key] = $value; } else { $items2[$key] = $value; } } return new static([new static($items1), new static($items2)]); }
php
public function partition(callable $predicate): ArrayCollection { $items1 = []; $items2 = []; foreach ($this->items as $key => $value) { if ($predicate($value, $key)) { $items1[$key] = $value; } else { $items2[$key] = $value; } } return new static([new static($items1), new static($items2)]); }
[ "public", "function", "partition", "(", "callable", "$", "predicate", ")", ":", "ArrayCollection", "{", "$", "items1", "=", "[", "]", ";", "$", "items2", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "predicate", "(", "$", "value", ",", "$", "key", ")", ")", "{", "$", "items1", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "$", "items2", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "new", "static", "(", "[", "new", "static", "(", "$", "items1", ")", ",", "new", "static", "(", "$", "items2", ")", "]", ")", ";", "}" ]
Creates a collection of two collections based on a truth test Items that pass the truth test are placed in the first collection. Items that fail the truth test are placed in the second collection. Predicate signature: <code> function ($value, $key): bool {} </code> @param callable $predicate The predicate function @return ArrayCollection
[ "Creates", "a", "collection", "of", "two", "collections", "based", "on", "a", "truth", "test" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1198-L1212
2,528
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.page
public function page(int $page, int $perPage): ArrayCollection { return $this->slice(($page - 1) * $perPage, $perPage); }
php
public function page(int $page, int $perPage): ArrayCollection { return $this->slice(($page - 1) * $perPage, $perPage); }
[ "public", "function", "page", "(", "int", "$", "page", ",", "int", "$", "perPage", ")", ":", "ArrayCollection", "{", "return", "$", "this", "->", "slice", "(", "(", "$", "page", "-", "1", ")", "*", "$", "perPage", ",", "$", "perPage", ")", ";", "}" ]
Creates a paginated collection @param int $page The page number @param int $perPage The number of items per page @return ArrayCollection
[ "Creates", "a", "paginated", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1222-L1225
2,529
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.implode
public function implode(?string $glue = null, ?callable $callback = null): string { if ($glue === null) { $glue = ''; } if ($callback !== null) { return implode($glue, $this->map($callback)->all()); } return implode($glue, $this->all()); }
php
public function implode(?string $glue = null, ?callable $callback = null): string { if ($glue === null) { $glue = ''; } if ($callback !== null) { return implode($glue, $this->map($callback)->all()); } return implode($glue, $this->all()); }
[ "public", "function", "implode", "(", "?", "string", "$", "glue", "=", "null", ",", "?", "callable", "$", "callback", "=", "null", ")", ":", "string", "{", "if", "(", "$", "glue", "===", "null", ")", "{", "$", "glue", "=", "''", ";", "}", "if", "(", "$", "callback", "!==", "null", ")", "{", "return", "implode", "(", "$", "glue", ",", "$", "this", "->", "map", "(", "$", "callback", ")", "->", "all", "(", ")", ")", ";", "}", "return", "implode", "(", "$", "glue", ",", "$", "this", "->", "all", "(", ")", ")", ";", "}" ]
Concatenates values into a string Optional callback should return a string value for concatenation. Callback signature: <code> function ($value, $key): string {} </code> @param string|null $glue The string to join around @param callable|null $callback The callback function @return string
[ "Concatenates", "values", "into", "a", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1243-L1254
2,530
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.join
public function join(?string $glue = null, ?callable $callback = null): string { return $this->implode($glue, $callback); }
php
public function join(?string $glue = null, ?callable $callback = null): string { return $this->implode($glue, $callback); }
[ "public", "function", "join", "(", "?", "string", "$", "glue", "=", "null", ",", "?", "callable", "$", "callback", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "implode", "(", "$", "glue", ",", "$", "callback", ")", ";", "}" ]
Alias for implode Optional callback should return a string value for concatenation. Callback signature: <code> function ($value, $key): string {} </code> @param string|null $glue The string to join around @param callable|null $callback The callback function @return string
[ "Alias", "for", "implode" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1272-L1275
2,531
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.reduce
public function reduce(callable $callback, $initial = null) { $accumulator = $initial; foreach ($this->items as $key => $value) { $accumulator = $callback($accumulator, $value, $key); } return $accumulator; }
php
public function reduce(callable $callback, $initial = null) { $accumulator = $initial; foreach ($this->items as $key => $value) { $accumulator = $callback($accumulator, $value, $key); } return $accumulator; }
[ "public", "function", "reduce", "(", "callable", "$", "callback", ",", "$", "initial", "=", "null", ")", "{", "$", "accumulator", "=", "$", "initial", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "accumulator", "=", "$", "callback", "(", "$", "accumulator", ",", "$", "value", ",", "$", "key", ")", ";", "}", "return", "$", "accumulator", ";", "}" ]
Reduces the collection to a single value The callback must return the accumulator. Callback signature: <code> function ($accumulator, $value, $key): mixed {} </code> @param callable $callback The callback function @param mixed $initial The initial value @return mixed
[ "Reduces", "the", "collection", "to", "a", "single", "value" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1293-L1302
2,532
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.sum
public function sum(?callable $callback = null) { if ($callback === null) { $callback = function ($value, $key) { return $value; }; } return $this->reduce(function ($total, $value, $key) use ($callback) { return $total + $callback($value, $key); }, 0); }
php
public function sum(?callable $callback = null) { if ($callback === null) { $callback = function ($value, $key) { return $value; }; } return $this->reduce(function ($total, $value, $key) use ($callback) { return $total + $callback($value, $key); }, 0); }
[ "public", "function", "sum", "(", "?", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", ")", "{", "$", "callback", "=", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "$", "value", ";", "}", ";", "}", "return", "$", "this", "->", "reduce", "(", "function", "(", "$", "total", ",", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ")", "{", "return", "$", "total", "+", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", ",", "0", ")", ";", "}" ]
Retrieves the sum of the collection The callback should return a value to sum. Callback signature: <code> function ($value, $key): mixed {} </code> @param callable|null $callback The callback function @return mixed
[ "Retrieves", "the", "sum", "of", "the", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1319-L1330
2,533
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.max
public function max(?callable $callback = null) { return $this->reduce(function ($result, $value, $key) use ($callback) { if ($callback !== null) { $value = $callback($value, $key); } return ($result === null) || $value > $result ? $value : $result; }); }
php
public function max(?callable $callback = null) { return $this->reduce(function ($result, $value, $key) use ($callback) { if ($callback !== null) { $value = $callback($value, $key); } return ($result === null) || $value > $result ? $value : $result; }); }
[ "public", "function", "max", "(", "?", "callable", "$", "callback", "=", "null", ")", "{", "return", "$", "this", "->", "reduce", "(", "function", "(", "$", "result", ",", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ")", "{", "if", "(", "$", "callback", "!==", "null", ")", "{", "$", "value", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", "return", "(", "$", "result", "===", "null", ")", "||", "$", "value", ">", "$", "result", "?", "$", "value", ":", "$", "result", ";", "}", ")", ";", "}" ]
Retrieves the maximum value for a collection The callback should return a value to compare. Callback signature: <code> function ($value, $key): mixed {} </code> @param callable|null $callback The callback function @return mixed
[ "Retrieves", "the", "maximum", "value", "for", "a", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1392-L1401
2,534
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.min
public function min(?callable $callback = null) { return $this->reduce(function ($result, $value, $key) use ($callback) { if ($callback !== null) { $value = $callback($value, $key); } return ($result === null) || $value < $result ? $value : $result; }); }
php
public function min(?callable $callback = null) { return $this->reduce(function ($result, $value, $key) use ($callback) { if ($callback !== null) { $value = $callback($value, $key); } return ($result === null) || $value < $result ? $value : $result; }); }
[ "public", "function", "min", "(", "?", "callable", "$", "callback", "=", "null", ")", "{", "return", "$", "this", "->", "reduce", "(", "function", "(", "$", "result", ",", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callback", ")", "{", "if", "(", "$", "callback", "!==", "null", ")", "{", "$", "value", "=", "$", "callback", "(", "$", "value", ",", "$", "key", ")", ";", "}", "return", "(", "$", "result", "===", "null", ")", "||", "$", "value", "<", "$", "result", "?", "$", "value", ":", "$", "result", ";", "}", ")", ";", "}" ]
Retrieves the minimum value for a collection The callback should return a value to compare. Callback signature: <code> function ($value, $key): mixed {} </code> @param callable|null $callback The callback function @return mixed
[ "Retrieves", "the", "minimum", "value", "for", "a", "collection" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1418-L1427
2,535
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.flattenArray
protected static function flattenArray(array $array, int $depth = PHP_INT_MAX): array { $items = []; foreach ($array as $item) { if ($item instanceof self) { $item = $item->all(); } if (is_array($item)) { if ($depth === 1) { $items = array_merge($items, $item); continue; } $items = array_merge($items, static::flattenArray($item, $depth - 1)); continue; } $items[] = $item; } return $items; }
php
protected static function flattenArray(array $array, int $depth = PHP_INT_MAX): array { $items = []; foreach ($array as $item) { if ($item instanceof self) { $item = $item->all(); } if (is_array($item)) { if ($depth === 1) { $items = array_merge($items, $item); continue; } $items = array_merge($items, static::flattenArray($item, $depth - 1)); continue; } $items[] = $item; } return $items; }
[ "protected", "static", "function", "flattenArray", "(", "array", "$", "array", ",", "int", "$", "depth", "=", "PHP_INT_MAX", ")", ":", "array", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "item", ")", "{", "if", "(", "$", "item", "instanceof", "self", ")", "{", "$", "item", "=", "$", "item", "->", "all", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "if", "(", "$", "depth", "===", "1", ")", "{", "$", "items", "=", "array_merge", "(", "$", "items", ",", "$", "item", ")", ";", "continue", ";", "}", "$", "items", "=", "array_merge", "(", "$", "items", ",", "static", "::", "flattenArray", "(", "$", "item", ",", "$", "depth", "-", "1", ")", ")", ";", "continue", ";", "}", "$", "items", "[", "]", "=", "$", "item", ";", "}", "return", "$", "items", ";", "}" ]
Flattens a multi-dimensional array into a single level @param array $array The array @param int $depth The depth @return array
[ "Flattens", "a", "multi", "-", "dimensional", "array", "into", "a", "single", "level" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1489-L1511
2,536
novuso/system
src/Collection/ArrayCollection.php
ArrayCollection.itemsArray
protected function itemsArray($items): array { if (is_array($items)) { return $items; } elseif ($items instanceof self) { return $items->all(); } elseif ($items instanceof Arrayable) { return $items->toArray(); } return (array) $items; }
php
protected function itemsArray($items): array { if (is_array($items)) { return $items; } elseif ($items instanceof self) { return $items->all(); } elseif ($items instanceof Arrayable) { return $items->toArray(); } return (array) $items; }
[ "protected", "function", "itemsArray", "(", "$", "items", ")", ":", "array", "{", "if", "(", "is_array", "(", "$", "items", ")", ")", "{", "return", "$", "items", ";", "}", "elseif", "(", "$", "items", "instanceof", "self", ")", "{", "return", "$", "items", "->", "all", "(", ")", ";", "}", "elseif", "(", "$", "items", "instanceof", "Arrayable", ")", "{", "return", "$", "items", "->", "toArray", "(", ")", ";", "}", "return", "(", "array", ")", "$", "items", ";", "}" ]
Retrieves items as an array @codeCoverageIgnore @param mixed $items The items @return array
[ "Retrieves", "items", "as", "an", "array" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/ArrayCollection.php#L1522-L1533
2,537
mostofreddy/resty
src/Http/Response.php
Response.ok
public function ok($data, int $status = 200, int $encodingOptions = 0) { $this->validHttpCode($status); return parent::withJson($data, $status, $encodingOptions); }
php
public function ok($data, int $status = 200, int $encodingOptions = 0) { $this->validHttpCode($status); return parent::withJson($data, $status, $encodingOptions); }
[ "public", "function", "ok", "(", "$", "data", ",", "int", "$", "status", "=", "200", ",", "int", "$", "encodingOptions", "=", "0", ")", "{", "$", "this", "->", "validHttpCode", "(", "$", "status", ")", ";", "return", "parent", "::", "withJson", "(", "$", "data", ",", "$", "status", ",", "$", "encodingOptions", ")", ";", "}" ]
Response data with 2xx status code @param mixed $data Mensaje de respuesta @param integer $status Http Code. Valores posibles: 2xx. Defecto: 200 @param integer $encodingOptions Flag de JSON para imprimir json. Ver: http://php.net/manual/es/json.constants.php @throws \InvalidArgumentException Si el httpcode es inválido @return Response
[ "Response", "data", "with", "2xx", "status", "code" ]
e20d8596bb14ee6db99aded82ed0221cc6d08462
https://github.com/mostofreddy/resty/blob/e20d8596bb14ee6db99aded82ed0221cc6d08462/src/Http/Response.php#L57-L61
2,538
AnonymPHP/Anonym-Library
src/Anonym/Route/Controller.php
Controller.runControllerWithParameters
public function runControllerWithParameters($parameters = []) { $this->setParameters($this->toArray($parameters)); foreach($this->callbacks as $callback){ $this->app->call($callback); } }
php
public function runControllerWithParameters($parameters = []) { $this->setParameters($this->toArray($parameters)); foreach($this->callbacks as $callback){ $this->app->call($callback); } }
[ "public", "function", "runControllerWithParameters", "(", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "setParameters", "(", "$", "this", "->", "toArray", "(", "$", "parameters", ")", ")", ";", "foreach", "(", "$", "this", "->", "callbacks", "as", "$", "callback", ")", "{", "$", "this", "->", "app", "->", "call", "(", "$", "callback", ")", ";", "}", "}" ]
register parameters and run constructors @param array $parameters
[ "register", "parameters", "and", "run", "constructors" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Route/Controller.php#L129-L137
2,539
tokenly/platform-admin
src/Jobs/ArtisanCommand.php
ArtisanCommand.handle
public function handle() { Log::debug("ArtisanCommand handle begin $this->command_string"); $input = new StringInput($this->command_string); $output = new PusherChannelOutput(); // init pusher $pusher = Broadcast::connection()->getPusher(); $channel_id = config('platformadmin.console.pusher_channel_base').$this->command_id; $output->setPusherConnectionAndChannel($pusher, $channel_id); // begin pushing updates $output->open(); // handle the artisan command $kernel = app(Kernel::class); $status = $kernel->handle($input, $output); $kernel->terminate($input, $status); // delay a bit to make sure the front-end loaded usleep(350000); $output->writeln(''); // wait a little longer and send the final output to pusher usleep(750000); $output->close($status); Log::debug("ArtisanCommand handle end $this->command_string"); }
php
public function handle() { Log::debug("ArtisanCommand handle begin $this->command_string"); $input = new StringInput($this->command_string); $output = new PusherChannelOutput(); // init pusher $pusher = Broadcast::connection()->getPusher(); $channel_id = config('platformadmin.console.pusher_channel_base').$this->command_id; $output->setPusherConnectionAndChannel($pusher, $channel_id); // begin pushing updates $output->open(); // handle the artisan command $kernel = app(Kernel::class); $status = $kernel->handle($input, $output); $kernel->terminate($input, $status); // delay a bit to make sure the front-end loaded usleep(350000); $output->writeln(''); // wait a little longer and send the final output to pusher usleep(750000); $output->close($status); Log::debug("ArtisanCommand handle end $this->command_string"); }
[ "public", "function", "handle", "(", ")", "{", "Log", "::", "debug", "(", "\"ArtisanCommand handle begin $this->command_string\"", ")", ";", "$", "input", "=", "new", "StringInput", "(", "$", "this", "->", "command_string", ")", ";", "$", "output", "=", "new", "PusherChannelOutput", "(", ")", ";", "// init pusher", "$", "pusher", "=", "Broadcast", "::", "connection", "(", ")", "->", "getPusher", "(", ")", ";", "$", "channel_id", "=", "config", "(", "'platformadmin.console.pusher_channel_base'", ")", ".", "$", "this", "->", "command_id", ";", "$", "output", "->", "setPusherConnectionAndChannel", "(", "$", "pusher", ",", "$", "channel_id", ")", ";", "// begin pushing updates", "$", "output", "->", "open", "(", ")", ";", "// handle the artisan command", "$", "kernel", "=", "app", "(", "Kernel", "::", "class", ")", ";", "$", "status", "=", "$", "kernel", "->", "handle", "(", "$", "input", ",", "$", "output", ")", ";", "$", "kernel", "->", "terminate", "(", "$", "input", ",", "$", "status", ")", ";", "// delay a bit to make sure the front-end loaded", "usleep", "(", "350000", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "// wait a little longer and send the final output to pusher", "usleep", "(", "750000", ")", ";", "$", "output", "->", "close", "(", "$", "status", ")", ";", "Log", "::", "debug", "(", "\"ArtisanCommand handle end $this->command_string\"", ")", ";", "}" ]
handle the job
[ "handle", "the", "job" ]
0b2f5d57552d493026df94edaa250b475407d588
https://github.com/tokenly/platform-admin/blob/0b2f5d57552d493026df94edaa250b475407d588/src/Jobs/ArtisanCommand.php#L29-L58
2,540
ghiencode/util
Service.php
Service.endpointsInfo
public static function endpointsInfo(Application $app) { $app->boot(); /** @var ControllerCollection $controllers */ $controllers = $app['controllers']; $rControllers = new ReflectionObject($controllers); $pControllers = $rControllers->getProperty('controllers'); $pControllers->setAccessible(true); /** @var Controller $ctrl */ foreach ($pControllers->getValue($controllers) as $ctrl) { if ($ctrl instanceof Controller) { $route = $ctrl->getRoute(); foreach ($route->getMethods() as $method) { echo '- ' . str_pad($method, 7) . ' ' . str_pad($route->getPath(), 70); if ($service = $route->getDefault('_controller')) { if (is_scalar($service)) { echo 'Handler: ' . $service; } } echo "\n"; } } } }
php
public static function endpointsInfo(Application $app) { $app->boot(); /** @var ControllerCollection $controllers */ $controllers = $app['controllers']; $rControllers = new ReflectionObject($controllers); $pControllers = $rControllers->getProperty('controllers'); $pControllers->setAccessible(true); /** @var Controller $ctrl */ foreach ($pControllers->getValue($controllers) as $ctrl) { if ($ctrl instanceof Controller) { $route = $ctrl->getRoute(); foreach ($route->getMethods() as $method) { echo '- ' . str_pad($method, 7) . ' ' . str_pad($route->getPath(), 70); if ($service = $route->getDefault('_controller')) { if (is_scalar($service)) { echo 'Handler: ' . $service; } } echo "\n"; } } } }
[ "public", "static", "function", "endpointsInfo", "(", "Application", "$", "app", ")", "{", "$", "app", "->", "boot", "(", ")", ";", "/** @var ControllerCollection $controllers */", "$", "controllers", "=", "$", "app", "[", "'controllers'", "]", ";", "$", "rControllers", "=", "new", "ReflectionObject", "(", "$", "controllers", ")", ";", "$", "pControllers", "=", "$", "rControllers", "->", "getProperty", "(", "'controllers'", ")", ";", "$", "pControllers", "->", "setAccessible", "(", "true", ")", ";", "/** @var Controller $ctrl */", "foreach", "(", "$", "pControllers", "->", "getValue", "(", "$", "controllers", ")", "as", "$", "ctrl", ")", "{", "if", "(", "$", "ctrl", "instanceof", "Controller", ")", "{", "$", "route", "=", "$", "ctrl", "->", "getRoute", "(", ")", ";", "foreach", "(", "$", "route", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "echo", "'- '", ".", "str_pad", "(", "$", "method", ",", "7", ")", ".", "' '", ".", "str_pad", "(", "$", "route", "->", "getPath", "(", ")", ",", "70", ")", ";", "if", "(", "$", "service", "=", "$", "route", "->", "getDefault", "(", "'_controller'", ")", ")", "{", "if", "(", "is_scalar", "(", "$", "service", ")", ")", "{", "echo", "'Handler: '", ".", "$", "service", ";", "}", "}", "echo", "\"\\n\"", ";", "}", "}", "}", "}" ]
Simple method to print application resources. @param Application $app
[ "Simple", "method", "to", "print", "application", "resources", "." ]
c27ead3cde04cc682055318a0836862aa7cd9d35
https://github.com/ghiencode/util/blob/c27ead3cde04cc682055318a0836862aa7cd9d35/Service.php#L37-L65
2,541
ttreeagency/Strapping.ElasticSearch
Classes/ViewHelpers/Widget/Controller/PaginateController.php
PaginateController.buildPagination
protected function buildPagination() { $this->calculateDisplayRange(); $pages = array(); for ($i = $this->displayRangeStart; $i <= $this->displayRangeEnd; $i++) { $pages[] = array('number' => $i, 'isCurrent' => ($i === $this->currentPage)); } $pagination = array( 'pages' => $pages, 'current' => $this->currentPage, 'numberOfPages' => $this->numberOfPages, 'displayRangeStart' => $this->displayRangeStart, 'displayRangeEnd' => $this->displayRangeEnd, 'hasLessPages' => $this->displayRangeStart > 2, 'hasMorePages' => $this->displayRangeEnd + 1 < $this->numberOfPages ); if ($this->currentPage < $this->numberOfPages) { $pagination['nextPage'] = $this->currentPage + 1; } if ($this->currentPage > 1) { $pagination['previousPage'] = $this->currentPage - 1; } return $pagination; }
php
protected function buildPagination() { $this->calculateDisplayRange(); $pages = array(); for ($i = $this->displayRangeStart; $i <= $this->displayRangeEnd; $i++) { $pages[] = array('number' => $i, 'isCurrent' => ($i === $this->currentPage)); } $pagination = array( 'pages' => $pages, 'current' => $this->currentPage, 'numberOfPages' => $this->numberOfPages, 'displayRangeStart' => $this->displayRangeStart, 'displayRangeEnd' => $this->displayRangeEnd, 'hasLessPages' => $this->displayRangeStart > 2, 'hasMorePages' => $this->displayRangeEnd + 1 < $this->numberOfPages ); if ($this->currentPage < $this->numberOfPages) { $pagination['nextPage'] = $this->currentPage + 1; } if ($this->currentPage > 1) { $pagination['previousPage'] = $this->currentPage - 1; } return $pagination; }
[ "protected", "function", "buildPagination", "(", ")", "{", "$", "this", "->", "calculateDisplayRange", "(", ")", ";", "$", "pages", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "this", "->", "displayRangeStart", ";", "$", "i", "<=", "$", "this", "->", "displayRangeEnd", ";", "$", "i", "++", ")", "{", "$", "pages", "[", "]", "=", "array", "(", "'number'", "=>", "$", "i", ",", "'isCurrent'", "=>", "(", "$", "i", "===", "$", "this", "->", "currentPage", ")", ")", ";", "}", "$", "pagination", "=", "array", "(", "'pages'", "=>", "$", "pages", ",", "'current'", "=>", "$", "this", "->", "currentPage", ",", "'numberOfPages'", "=>", "$", "this", "->", "numberOfPages", ",", "'displayRangeStart'", "=>", "$", "this", "->", "displayRangeStart", ",", "'displayRangeEnd'", "=>", "$", "this", "->", "displayRangeEnd", ",", "'hasLessPages'", "=>", "$", "this", "->", "displayRangeStart", ">", "2", ",", "'hasMorePages'", "=>", "$", "this", "->", "displayRangeEnd", "+", "1", "<", "$", "this", "->", "numberOfPages", ")", ";", "if", "(", "$", "this", "->", "currentPage", "<", "$", "this", "->", "numberOfPages", ")", "{", "$", "pagination", "[", "'nextPage'", "]", "=", "$", "this", "->", "currentPage", "+", "1", ";", "}", "if", "(", "$", "this", "->", "currentPage", ">", "1", ")", "{", "$", "pagination", "[", "'previousPage'", "]", "=", "$", "this", "->", "currentPage", "-", "1", ";", "}", "return", "$", "pagination", ";", "}" ]
Returns an array with the keys "pages", "current", "numberOfPages", "nextPage" & "previousPage" @return array
[ "Returns", "an", "array", "with", "the", "keys", "pages", "current", "numberOfPages", "nextPage", "&", "previousPage" ]
c79892a5264d61ba6ca763021eef1af9b80c0a6f
https://github.com/ttreeagency/Strapping.ElasticSearch/blob/c79892a5264d61ba6ca763021eef1af9b80c0a6f/Classes/ViewHelpers/Widget/Controller/PaginateController.php#L125-L148
2,542
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/date.php
Date.create_from_string
public static function create_from_string($input, $pattern_key = 'local') { \Config::load('date', 'date'); $pattern = \Config::get('date.patterns.'.$pattern_key, null); empty($pattern) and $pattern = $pattern_key; $time = strptime($input, $pattern); if ($time === false) { throw new \UnexpectedValueException('Input was not recognized by pattern.'); } // convert it into a timestamp $timestamp = mktime($time['tm_hour'], $time['tm_min'], $time['tm_sec'], $time['tm_mon'] + 1, $time['tm_mday'], $time['tm_year'] + 1900); if ($timestamp === false) { throw new \OutOfBoundsException('Input was invalid.'.(PHP_INT_SIZE == 4?' A 32-bit system only supports dates between 1901 and 2038.':'')); } return static::forge($timestamp); }
php
public static function create_from_string($input, $pattern_key = 'local') { \Config::load('date', 'date'); $pattern = \Config::get('date.patterns.'.$pattern_key, null); empty($pattern) and $pattern = $pattern_key; $time = strptime($input, $pattern); if ($time === false) { throw new \UnexpectedValueException('Input was not recognized by pattern.'); } // convert it into a timestamp $timestamp = mktime($time['tm_hour'], $time['tm_min'], $time['tm_sec'], $time['tm_mon'] + 1, $time['tm_mday'], $time['tm_year'] + 1900); if ($timestamp === false) { throw new \OutOfBoundsException('Input was invalid.'.(PHP_INT_SIZE == 4?' A 32-bit system only supports dates between 1901 and 2038.':'')); } return static::forge($timestamp); }
[ "public", "static", "function", "create_from_string", "(", "$", "input", ",", "$", "pattern_key", "=", "'local'", ")", "{", "\\", "Config", "::", "load", "(", "'date'", ",", "'date'", ")", ";", "$", "pattern", "=", "\\", "Config", "::", "get", "(", "'date.patterns.'", ".", "$", "pattern_key", ",", "null", ")", ";", "empty", "(", "$", "pattern", ")", "and", "$", "pattern", "=", "$", "pattern_key", ";", "$", "time", "=", "strptime", "(", "$", "input", ",", "$", "pattern", ")", ";", "if", "(", "$", "time", "===", "false", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Input was not recognized by pattern.'", ")", ";", "}", "// convert it into a timestamp", "$", "timestamp", "=", "mktime", "(", "$", "time", "[", "'tm_hour'", "]", ",", "$", "time", "[", "'tm_min'", "]", ",", "$", "time", "[", "'tm_sec'", "]", ",", "$", "time", "[", "'tm_mon'", "]", "+", "1", ",", "$", "time", "[", "'tm_mday'", "]", ",", "$", "time", "[", "'tm_year'", "]", "+", "1900", ")", ";", "if", "(", "$", "timestamp", "===", "false", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "'Input was invalid.'", ".", "(", "PHP_INT_SIZE", "==", "4", "?", "' A 32-bit system only supports dates between 1901 and 2038.'", ":", "''", ")", ")", ";", "}", "return", "static", "::", "forge", "(", "$", "timestamp", ")", ";", "}" ]
Uses the date config file to translate string input to timestamp @param string date/time input @param string key name of pattern in config file @return Date
[ "Uses", "the", "date", "config", "file", "to", "translate", "string", "input", "to", "timestamp" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/date.php#L161-L184
2,543
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/date.php
Date.range_to_array
public static function range_to_array($start, $end, $interval = '+1 Day') { $start = ( ! $start instanceof Date) ? static::forge($start) : $start; $end = ( ! $end instanceof Date) ? static::forge($end) : $end; is_int($interval) or $interval = strtotime($interval, $start->get_timestamp()) - $start->get_timestamp(); if ($interval <= 0) { throw new \UnexpectedValueException('Input was not recognized by pattern.'); } $range = array(); $current = $start; while ($current->get_timestamp() <= $end->get_timestamp()) { $range[] = $current; $current = static::forge($current->get_timestamp() + $interval); } return $range; }
php
public static function range_to_array($start, $end, $interval = '+1 Day') { $start = ( ! $start instanceof Date) ? static::forge($start) : $start; $end = ( ! $end instanceof Date) ? static::forge($end) : $end; is_int($interval) or $interval = strtotime($interval, $start->get_timestamp()) - $start->get_timestamp(); if ($interval <= 0) { throw new \UnexpectedValueException('Input was not recognized by pattern.'); } $range = array(); $current = $start; while ($current->get_timestamp() <= $end->get_timestamp()) { $range[] = $current; $current = static::forge($current->get_timestamp() + $interval); } return $range; }
[ "public", "static", "function", "range_to_array", "(", "$", "start", ",", "$", "end", ",", "$", "interval", "=", "'+1 Day'", ")", "{", "$", "start", "=", "(", "!", "$", "start", "instanceof", "Date", ")", "?", "static", "::", "forge", "(", "$", "start", ")", ":", "$", "start", ";", "$", "end", "=", "(", "!", "$", "end", "instanceof", "Date", ")", "?", "static", "::", "forge", "(", "$", "end", ")", ":", "$", "end", ";", "is_int", "(", "$", "interval", ")", "or", "$", "interval", "=", "strtotime", "(", "$", "interval", ",", "$", "start", "->", "get_timestamp", "(", ")", ")", "-", "$", "start", "->", "get_timestamp", "(", ")", ";", "if", "(", "$", "interval", "<=", "0", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Input was not recognized by pattern.'", ")", ";", "}", "$", "range", "=", "array", "(", ")", ";", "$", "current", "=", "$", "start", ";", "while", "(", "$", "current", "->", "get_timestamp", "(", ")", "<=", "$", "end", "->", "get_timestamp", "(", ")", ")", "{", "$", "range", "[", "]", "=", "$", "current", ";", "$", "current", "=", "static", "::", "forge", "(", "$", "current", "->", "get_timestamp", "(", ")", "+", "$", "interval", ")", ";", "}", "return", "$", "range", ";", "}" ]
Fetches an array of Date objects per interval within a range @param int|Date start of the range @param int|Date end of the range @param int|string Length of the interval in seconds or valid strtotime time difference @return array array of Date objects
[ "Fetches", "an", "array", "of", "Date", "objects", "per", "interval", "within", "a", "range" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/date.php#L194-L216
2,544
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/date.php
Date.time_ago
public static function time_ago($timestamp, $from_timestamp = null, $unit = null) { if ($timestamp === null) { return ''; } ! is_numeric($timestamp) and $timestamp = static::create_from_string($timestamp)->get_timestamp(); $from_timestamp == null and $from_timestamp = time(); \Lang::load('date', true); $difference = $from_timestamp - $timestamp; $periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade'); $lengths = array(60, 60, 24, 7, 4.35, 12, 10); for ($j = 0; isset($lengths[$j]) and $difference >= $lengths[$j] and (empty($unit) or $unit != $periods[$j]); $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if ($difference != 1) { $periods[$j] = \Inflector::pluralize($periods[$j]); } $text = \Lang::get('date.text', array( 'time' => \Lang::get('date.'.$periods[$j], array('t' => $difference)) )); return $text; }
php
public static function time_ago($timestamp, $from_timestamp = null, $unit = null) { if ($timestamp === null) { return ''; } ! is_numeric($timestamp) and $timestamp = static::create_from_string($timestamp)->get_timestamp(); $from_timestamp == null and $from_timestamp = time(); \Lang::load('date', true); $difference = $from_timestamp - $timestamp; $periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade'); $lengths = array(60, 60, 24, 7, 4.35, 12, 10); for ($j = 0; isset($lengths[$j]) and $difference >= $lengths[$j] and (empty($unit) or $unit != $periods[$j]); $j++) { $difference /= $lengths[$j]; } $difference = round($difference); if ($difference != 1) { $periods[$j] = \Inflector::pluralize($periods[$j]); } $text = \Lang::get('date.text', array( 'time' => \Lang::get('date.'.$periods[$j], array('t' => $difference)) )); return $text; }
[ "public", "static", "function", "time_ago", "(", "$", "timestamp", ",", "$", "from_timestamp", "=", "null", ",", "$", "unit", "=", "null", ")", "{", "if", "(", "$", "timestamp", "===", "null", ")", "{", "return", "''", ";", "}", "!", "is_numeric", "(", "$", "timestamp", ")", "and", "$", "timestamp", "=", "static", "::", "create_from_string", "(", "$", "timestamp", ")", "->", "get_timestamp", "(", ")", ";", "$", "from_timestamp", "==", "null", "and", "$", "from_timestamp", "=", "time", "(", ")", ";", "\\", "Lang", "::", "load", "(", "'date'", ",", "true", ")", ";", "$", "difference", "=", "$", "from_timestamp", "-", "$", "timestamp", ";", "$", "periods", "=", "array", "(", "'second'", ",", "'minute'", ",", "'hour'", ",", "'day'", ",", "'week'", ",", "'month'", ",", "'year'", ",", "'decade'", ")", ";", "$", "lengths", "=", "array", "(", "60", ",", "60", ",", "24", ",", "7", ",", "4.35", ",", "12", ",", "10", ")", ";", "for", "(", "$", "j", "=", "0", ";", "isset", "(", "$", "lengths", "[", "$", "j", "]", ")", "and", "$", "difference", ">=", "$", "lengths", "[", "$", "j", "]", "and", "(", "empty", "(", "$", "unit", ")", "or", "$", "unit", "!=", "$", "periods", "[", "$", "j", "]", ")", ";", "$", "j", "++", ")", "{", "$", "difference", "/=", "$", "lengths", "[", "$", "j", "]", ";", "}", "$", "difference", "=", "round", "(", "$", "difference", ")", ";", "if", "(", "$", "difference", "!=", "1", ")", "{", "$", "periods", "[", "$", "j", "]", "=", "\\", "Inflector", "::", "pluralize", "(", "$", "periods", "[", "$", "j", "]", ")", ";", "}", "$", "text", "=", "\\", "Lang", "::", "get", "(", "'date.text'", ",", "array", "(", "'time'", "=>", "\\", "Lang", "::", "get", "(", "'date.'", ".", "$", "periods", "[", "$", "j", "]", ",", "array", "(", "'t'", "=>", "$", "difference", ")", ")", ")", ")", ";", "return", "$", "text", ";", "}" ]
Returns the time ago @param int UNIX timestamp from current server @param int UNIX timestamp to compare against. Default to the current time @param string Unit to return the result in @return string Time ago
[ "Returns", "the", "time", "ago" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/date.php#L254-L288
2,545
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/date.php
Date.format
public function format($pattern_key = 'local', $timezone = null) { \Config::load('date', 'date'); $pattern = \Config::get('date.patterns.'.$pattern_key, $pattern_key); // determine the timezone to switch to $timezone === true and $timezone = static::$display_timezone; is_string($timezone) or $timezone = $this->timezone; // Temporarily change timezone when different from default if (\Fuel::$timezone != $timezone) { date_default_timezone_set($timezone); } // Create output $output = strftime($pattern, $this->timestamp); // Change timezone back to default if changed previously if (\Fuel::$timezone != $timezone) { date_default_timezone_set(\Fuel::$timezone); } return $output; }
php
public function format($pattern_key = 'local', $timezone = null) { \Config::load('date', 'date'); $pattern = \Config::get('date.patterns.'.$pattern_key, $pattern_key); // determine the timezone to switch to $timezone === true and $timezone = static::$display_timezone; is_string($timezone) or $timezone = $this->timezone; // Temporarily change timezone when different from default if (\Fuel::$timezone != $timezone) { date_default_timezone_set($timezone); } // Create output $output = strftime($pattern, $this->timestamp); // Change timezone back to default if changed previously if (\Fuel::$timezone != $timezone) { date_default_timezone_set(\Fuel::$timezone); } return $output; }
[ "public", "function", "format", "(", "$", "pattern_key", "=", "'local'", ",", "$", "timezone", "=", "null", ")", "{", "\\", "Config", "::", "load", "(", "'date'", ",", "'date'", ")", ";", "$", "pattern", "=", "\\", "Config", "::", "get", "(", "'date.patterns.'", ".", "$", "pattern_key", ",", "$", "pattern_key", ")", ";", "// determine the timezone to switch to", "$", "timezone", "===", "true", "and", "$", "timezone", "=", "static", "::", "$", "display_timezone", ";", "is_string", "(", "$", "timezone", ")", "or", "$", "timezone", "=", "$", "this", "->", "timezone", ";", "// Temporarily change timezone when different from default", "if", "(", "\\", "Fuel", "::", "$", "timezone", "!=", "$", "timezone", ")", "{", "date_default_timezone_set", "(", "$", "timezone", ")", ";", "}", "// Create output", "$", "output", "=", "strftime", "(", "$", "pattern", ",", "$", "this", "->", "timestamp", ")", ";", "// Change timezone back to default if changed previously", "if", "(", "\\", "Fuel", "::", "$", "timezone", "!=", "$", "timezone", ")", "{", "date_default_timezone_set", "(", "\\", "Fuel", "::", "$", "timezone", ")", ";", "}", "return", "$", "output", ";", "}" ]
Returns the date formatted according to the current locale @param string either a named pattern from date config file or a pattern, defaults to 'local' @param mixed vald timezone, or if true, output the time in local time instead of system time @return string
[ "Returns", "the", "date", "formatted", "according", "to", "the", "current", "locale" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/date.php#L316-L342
2,546
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/date.php
Date.get_timezone_abbr
public function get_timezone_abbr($display_timezone = false) { // determine the timezone to switch to $display_timezone and $timezone = static::$display_timezone; empty($timezone) and $timezone = $this->timezone; // Temporarily change timezone when different from default if (\Fuel::$timezone != $timezone) { date_default_timezone_set($timezone); } // Create output $output = date('T'); // Change timezone back to default if changed previously if (\Fuel::$timezone != $timezone) { date_default_timezone_set(\Fuel::$timezone); } return $output; }
php
public function get_timezone_abbr($display_timezone = false) { // determine the timezone to switch to $display_timezone and $timezone = static::$display_timezone; empty($timezone) and $timezone = $this->timezone; // Temporarily change timezone when different from default if (\Fuel::$timezone != $timezone) { date_default_timezone_set($timezone); } // Create output $output = date('T'); // Change timezone back to default if changed previously if (\Fuel::$timezone != $timezone) { date_default_timezone_set(\Fuel::$timezone); } return $output; }
[ "public", "function", "get_timezone_abbr", "(", "$", "display_timezone", "=", "false", ")", "{", "// determine the timezone to switch to", "$", "display_timezone", "and", "$", "timezone", "=", "static", "::", "$", "display_timezone", ";", "empty", "(", "$", "timezone", ")", "and", "$", "timezone", "=", "$", "this", "->", "timezone", ";", "// Temporarily change timezone when different from default", "if", "(", "\\", "Fuel", "::", "$", "timezone", "!=", "$", "timezone", ")", "{", "date_default_timezone_set", "(", "$", "timezone", ")", ";", "}", "// Create output", "$", "output", "=", "date", "(", "'T'", ")", ";", "// Change timezone back to default if changed previously", "if", "(", "\\", "Fuel", "::", "$", "timezone", "!=", "$", "timezone", ")", "{", "date_default_timezone_set", "(", "\\", "Fuel", "::", "$", "timezone", ")", ";", "}", "return", "$", "output", ";", "}" ]
Returns the internal timezone or the display timezone abbreviation @return string
[ "Returns", "the", "internal", "timezone", "or", "the", "display", "timezone", "abbreviation" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/date.php#L369-L391
2,547
randomhost/icinga-notification
src/php/NotifyMyAndroid.php
NotifyMyAndroid.send
protected function send() { try { $options = $this->getOptions(); $message = sprintf( 'Service: %2$s' . PHP_EOL . 'Host: %3$s' . PHP_EOL . 'State: %5$s' . PHP_EOL . 'Message: %7$s', $options['type'], $options['service'], $options['host'], $options['address'], $options['state'], $options['time'], $options['output'] ); $priority = $this->determinePriority($options['state']); // verify API key $this->nmaClient->verify(); // send notification $this->nmaClient->notify( self::SENDER, $options['type'], $message, $priority, 'anag://open?updateonreceive=true' ); $this->setMessage('Message was sent'); $this->setCode(self::STATE_OK); } catch (Exception $e) { $this->setMessage( 'Message could not be sent. Error from NMA client: ' . $e->getMessage() ); $this->setCode(self::STATE_CRITICAL); } return $this; }
php
protected function send() { try { $options = $this->getOptions(); $message = sprintf( 'Service: %2$s' . PHP_EOL . 'Host: %3$s' . PHP_EOL . 'State: %5$s' . PHP_EOL . 'Message: %7$s', $options['type'], $options['service'], $options['host'], $options['address'], $options['state'], $options['time'], $options['output'] ); $priority = $this->determinePriority($options['state']); // verify API key $this->nmaClient->verify(); // send notification $this->nmaClient->notify( self::SENDER, $options['type'], $message, $priority, 'anag://open?updateonreceive=true' ); $this->setMessage('Message was sent'); $this->setCode(self::STATE_OK); } catch (Exception $e) { $this->setMessage( 'Message could not be sent. Error from NMA client: ' . $e->getMessage() ); $this->setCode(self::STATE_CRITICAL); } return $this; }
[ "protected", "function", "send", "(", ")", "{", "try", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "$", "message", "=", "sprintf", "(", "'Service: %2$s'", ".", "PHP_EOL", ".", "'Host: %3$s'", ".", "PHP_EOL", ".", "'State: %5$s'", ".", "PHP_EOL", ".", "'Message: %7$s'", ",", "$", "options", "[", "'type'", "]", ",", "$", "options", "[", "'service'", "]", ",", "$", "options", "[", "'host'", "]", ",", "$", "options", "[", "'address'", "]", ",", "$", "options", "[", "'state'", "]", ",", "$", "options", "[", "'time'", "]", ",", "$", "options", "[", "'output'", "]", ")", ";", "$", "priority", "=", "$", "this", "->", "determinePriority", "(", "$", "options", "[", "'state'", "]", ")", ";", "// verify API key", "$", "this", "->", "nmaClient", "->", "verify", "(", ")", ";", "// send notification", "$", "this", "->", "nmaClient", "->", "notify", "(", "self", "::", "SENDER", ",", "$", "options", "[", "'type'", "]", ",", "$", "message", ",", "$", "priority", ",", "'anag://open?updateonreceive=true'", ")", ";", "$", "this", "->", "setMessage", "(", "'Message was sent'", ")", ";", "$", "this", "->", "setCode", "(", "self", "::", "STATE_OK", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "setMessage", "(", "'Message could not be sent. Error from NMA client: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "setCode", "(", "self", "::", "STATE_CRITICAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sends the notification to the given Android device. @return $this
[ "Sends", "the", "notification", "to", "the", "given", "Android", "device", "." ]
ab7ef279d19fd993d0fd6e39f2d219b768e48ce6
https://github.com/randomhost/icinga-notification/blob/ab7ef279d19fd993d0fd6e39f2d219b768e48ce6/src/php/NotifyMyAndroid.php#L116-L160
2,548
randomhost/icinga-notification
src/php/NotifyMyAndroid.php
NotifyMyAndroid.determinePriority
protected function determinePriority($state) { $priority = 0; if (array_key_exists($state, $this->stateToPriorityMap)) { $priority = $this->stateToPriorityMap[$state]; } return $priority; }
php
protected function determinePriority($state) { $priority = 0; if (array_key_exists($state, $this->stateToPriorityMap)) { $priority = $this->stateToPriorityMap[$state]; } return $priority; }
[ "protected", "function", "determinePriority", "(", "$", "state", ")", "{", "$", "priority", "=", "0", ";", "if", "(", "array_key_exists", "(", "$", "state", ",", "$", "this", "->", "stateToPriorityMap", ")", ")", "{", "$", "priority", "=", "$", "this", "->", "stateToPriorityMap", "[", "$", "state", "]", ";", "}", "return", "$", "priority", ";", "}" ]
Returns the priority for the given host or service state. @param string $state Host or service state. @return int
[ "Returns", "the", "priority", "for", "the", "given", "host", "or", "service", "state", "." ]
ab7ef279d19fd993d0fd6e39f2d219b768e48ce6
https://github.com/randomhost/icinga-notification/blob/ab7ef279d19fd993d0fd6e39f2d219b768e48ce6/src/php/NotifyMyAndroid.php#L169-L178
2,549
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Log/Structure/ContentView.php
ContentView.getDescription
public function getDescription() { if ( empty( $this->paragraphId ) ) { return ''; } $model = $this->getServiceLocator() ->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $locale = $model->getLocale(); $model->setLocale( $this->locale ); $content = $model->find( $this->paragraphId ); $model->setLocale( $locale ); if ( empty( $content ) ) { return $this->originalTitle; } else if ( ! empty( $content->title ) ) { return $content->title; } else if ( ! empty( $content->name ) ) { return $content->name; } else { return $this->originalTitle; } }
php
public function getDescription() { if ( empty( $this->paragraphId ) ) { return ''; } $model = $this->getServiceLocator() ->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $locale = $model->getLocale(); $model->setLocale( $this->locale ); $content = $model->find( $this->paragraphId ); $model->setLocale( $locale ); if ( empty( $content ) ) { return $this->originalTitle; } else if ( ! empty( $content->title ) ) { return $content->title; } else if ( ! empty( $content->name ) ) { return $content->name; } else { return $this->originalTitle; } }
[ "public", "function", "getDescription", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "paragraphId", ")", ")", "{", "return", "''", ";", "}", "$", "model", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", ";", "$", "locale", "=", "$", "model", "->", "getLocale", "(", ")", ";", "$", "model", "->", "setLocale", "(", "$", "this", "->", "locale", ")", ";", "$", "content", "=", "$", "model", "->", "find", "(", "$", "this", "->", "paragraphId", ")", ";", "$", "model", "->", "setLocale", "(", "$", "locale", ")", ";", "if", "(", "empty", "(", "$", "content", ")", ")", "{", "return", "$", "this", "->", "originalTitle", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "content", "->", "title", ")", ")", "{", "return", "$", "content", "->", "title", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "content", "->", "name", ")", ")", "{", "return", "$", "content", "->", "name", ";", "}", "else", "{", "return", "$", "this", "->", "originalTitle", ";", "}", "}" ]
Get description for this log-event @return string
[ "Get", "description", "for", "this", "log", "-", "event" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Log/Structure/ContentView.php#L49-L79
2,550
rinvex/obsolete-attributable
src/Support/RelationBuilder.php
RelationBuilder.getRelationClosure
protected function getRelationClosure(Entity $entity, Attribute $attribute) { $method = $attribute->is_collection ? 'hasMany' : 'hasOne'; // This will return a closure fully binded to the current entity instance, // which will help us to simulate any relation as if it was made in the // original entity class definition using a function statement. return Closure::bind(function () use ($entity, $attribute, $method) { $relation = $entity->$method($attribute->getAttribute('type'), 'entity_id', 'id'); // Since an attribute could be attached to multiple entities, then values could have // same entity ID, but for different entity types, so we need to add type where // clause to fetch only values related to the given entity ID + entity type. $relation->where('entity_type', get_class($entity)); // We add a where clause in order to fetch only the elements that are // related to the given attribute. If no condition is set, it will // fetch all the value rows related to the current entity. return $relation->where($attribute->getForeignKey(), $attribute->getKey()); }, $entity, get_class($entity)); }
php
protected function getRelationClosure(Entity $entity, Attribute $attribute) { $method = $attribute->is_collection ? 'hasMany' : 'hasOne'; // This will return a closure fully binded to the current entity instance, // which will help us to simulate any relation as if it was made in the // original entity class definition using a function statement. return Closure::bind(function () use ($entity, $attribute, $method) { $relation = $entity->$method($attribute->getAttribute('type'), 'entity_id', 'id'); // Since an attribute could be attached to multiple entities, then values could have // same entity ID, but for different entity types, so we need to add type where // clause to fetch only values related to the given entity ID + entity type. $relation->where('entity_type', get_class($entity)); // We add a where clause in order to fetch only the elements that are // related to the given attribute. If no condition is set, it will // fetch all the value rows related to the current entity. return $relation->where($attribute->getForeignKey(), $attribute->getKey()); }, $entity, get_class($entity)); }
[ "protected", "function", "getRelationClosure", "(", "Entity", "$", "entity", ",", "Attribute", "$", "attribute", ")", "{", "$", "method", "=", "$", "attribute", "->", "is_collection", "?", "'hasMany'", ":", "'hasOne'", ";", "// This will return a closure fully binded to the current entity instance,", "// which will help us to simulate any relation as if it was made in the", "// original entity class definition using a function statement.", "return", "Closure", "::", "bind", "(", "function", "(", ")", "use", "(", "$", "entity", ",", "$", "attribute", ",", "$", "method", ")", "{", "$", "relation", "=", "$", "entity", "->", "$", "method", "(", "$", "attribute", "->", "getAttribute", "(", "'type'", ")", ",", "'entity_id'", ",", "'id'", ")", ";", "// Since an attribute could be attached to multiple entities, then values could have", "// same entity ID, but for different entity types, so we need to add type where", "// clause to fetch only values related to the given entity ID + entity type.", "$", "relation", "->", "where", "(", "'entity_type'", ",", "get_class", "(", "$", "entity", ")", ")", ";", "// We add a where clause in order to fetch only the elements that are", "// related to the given attribute. If no condition is set, it will", "// fetch all the value rows related to the current entity.", "return", "$", "relation", "->", "where", "(", "$", "attribute", "->", "getForeignKey", "(", ")", ",", "$", "attribute", "->", "getKey", "(", ")", ")", ";", "}", ",", "$", "entity", ",", "get_class", "(", "$", "entity", ")", ")", ";", "}" ]
Generate the entity attribute relation closure. @param \Illuminate\Database\Eloquent\Model $entity @param \Rinvex\Attributable\Models\Attribute $attribute @return \Closure
[ "Generate", "the", "entity", "attribute", "relation", "closure", "." ]
23fa78efda9c24e2e1579917967537a3b3b9e4ce
https://github.com/rinvex/obsolete-attributable/blob/23fa78efda9c24e2e1579917967537a3b3b9e4ce/src/Support/RelationBuilder.php#L42-L62
2,551
ehough/shortstop
src/main/php/ehough/shortstop/api/HttpMessage.php
ehough_shortstop_api_HttpMessage.getHeaderValue
public final function getHeaderValue($name) { self::checkString($name); foreach ($this->_headers as $headerName => $headerValue) { if (strcasecmp($name, $headerName) === 0) { return $headerValue; } } return null; }
php
public final function getHeaderValue($name) { self::checkString($name); foreach ($this->_headers as $headerName => $headerValue) { if (strcasecmp($name, $headerName) === 0) { return $headerValue; } } return null; }
[ "public", "final", "function", "getHeaderValue", "(", "$", "name", ")", "{", "self", "::", "checkString", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "headerName", "=>", "$", "headerValue", ")", "{", "if", "(", "strcasecmp", "(", "$", "name", ",", "$", "headerName", ")", "===", "0", ")", "{", "return", "$", "headerValue", ";", "}", "}", "return", "null", ";", "}" ]
Find a header value by header name. @param string $name The header name to lookup. @return string The header value. May be null.
[ "Find", "a", "header", "value", "by", "header", "name", "." ]
4cef21457741347546c70e8e5c0cef6d3162b257
https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/api/HttpMessage.php#L68-L81
2,552
ehough/shortstop
src/main/php/ehough/shortstop/api/HttpMessage.php
ehough_shortstop_api_HttpMessage.setHeader
public final function setHeader($name, $value) { self::checkString($name); self::checkString($value); $this->_headers[$name] = $value; }
php
public final function setHeader($name, $value) { self::checkString($name); self::checkString($value); $this->_headers[$name] = $value; }
[ "public", "final", "function", "setHeader", "(", "$", "name", ",", "$", "value", ")", "{", "self", "::", "checkString", "(", "$", "name", ")", ";", "self", "::", "checkString", "(", "$", "value", ")", ";", "$", "this", "->", "_headers", "[", "$", "name", "]", "=", "$", "value", ";", "}" ]
Set a single header. @param string $name The header name. @param string $value The header value. @return void
[ "Set", "a", "single", "header", "." ]
4cef21457741347546c70e8e5c0cef6d3162b257
https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/api/HttpMessage.php#L91-L97
2,553
ehough/shortstop
src/main/php/ehough/shortstop/api/HttpMessage.php
ehough_shortstop_api_HttpMessage.removeHeaders
public final function removeHeaders($name) { self::checkString($name); foreach ($this->_headers as $headerName => $headerValue) { if (strcasecmp($name, $headerName) === 0) { unset($this->_headers[$headerName]); } } }
php
public final function removeHeaders($name) { self::checkString($name); foreach ($this->_headers as $headerName => $headerValue) { if (strcasecmp($name, $headerName) === 0) { unset($this->_headers[$headerName]); } } }
[ "public", "final", "function", "removeHeaders", "(", "$", "name", ")", "{", "self", "::", "checkString", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "headerName", "=>", "$", "headerValue", ")", "{", "if", "(", "strcasecmp", "(", "$", "name", ",", "$", "headerName", ")", "===", "0", ")", "{", "unset", "(", "$", "this", "->", "_headers", "[", "$", "headerName", "]", ")", ";", "}", "}", "}" ]
Removes any headers with the given name. @param string $name The header name. @return void
[ "Removes", "any", "headers", "with", "the", "given", "name", "." ]
4cef21457741347546c70e8e5c0cef6d3162b257
https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/api/HttpMessage.php#L119-L130
2,554
agalbourdin/agl-core
src/Mysql/Query/Delete.php
Delete.commit
public function commit($pWithChilds = false) { try { $prepared = Agl::app()->getDb()->getConnection()->prepare(" DELETE FROM `" . $this->getDbPrefix() . $this->_item->getDbContainer() . "` WHERE `" . $this->_item->getDbContainer() . ItemInterface::PREFIX_SEPARATOR . ItemInterface::IDFIELD . "` = :" . ItemInterface::IDFIELD . " "); $preparedValues = array( ItemInterface::IDFIELD => $this->_item->getId()->getOrig() ); if (! $prepared->execute($preparedValues)) { $error = $prepared->errorInfo(); throw new Exception("The delete query failed (table '" . $this->getDbPrefix() . $this->_item->getDbContainer() . "') with message '" . $error[2] . "'"); } if ($pWithChilds) { $this->_item->removeJoinFromAllChilds(); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $prepared->rowCount(); } catch (Exception $e) { throw new Exception($e); } return true; }
php
public function commit($pWithChilds = false) { try { $prepared = Agl::app()->getDb()->getConnection()->prepare(" DELETE FROM `" . $this->getDbPrefix() . $this->_item->getDbContainer() . "` WHERE `" . $this->_item->getDbContainer() . ItemInterface::PREFIX_SEPARATOR . ItemInterface::IDFIELD . "` = :" . ItemInterface::IDFIELD . " "); $preparedValues = array( ItemInterface::IDFIELD => $this->_item->getId()->getOrig() ); if (! $prepared->execute($preparedValues)) { $error = $prepared->errorInfo(); throw new Exception("The delete query failed (table '" . $this->getDbPrefix() . $this->_item->getDbContainer() . "') with message '" . $error[2] . "'"); } if ($pWithChilds) { $this->_item->removeJoinFromAllChilds(); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $prepared->rowCount(); } catch (Exception $e) { throw new Exception($e); } return true; }
[ "public", "function", "commit", "(", "$", "pWithChilds", "=", "false", ")", "{", "try", "{", "$", "prepared", "=", "Agl", "::", "app", "(", ")", "->", "getDb", "(", ")", "->", "getConnection", "(", ")", "->", "prepare", "(", "\"\n DELETE\n FROM\n `\"", ".", "$", "this", "->", "getDbPrefix", "(", ")", ".", "$", "this", "->", "_item", "->", "getDbContainer", "(", ")", ".", "\"`\n WHERE\n `\"", ".", "$", "this", "->", "_item", "->", "getDbContainer", "(", ")", ".", "ItemInterface", "::", "PREFIX_SEPARATOR", ".", "ItemInterface", "::", "IDFIELD", ".", "\"` = :\"", ".", "ItemInterface", "::", "IDFIELD", ".", "\"\n \"", ")", ";", "$", "preparedValues", "=", "array", "(", "ItemInterface", "::", "IDFIELD", "=>", "$", "this", "->", "_item", "->", "getId", "(", ")", "->", "getOrig", "(", ")", ")", ";", "if", "(", "!", "$", "prepared", "->", "execute", "(", "$", "preparedValues", ")", ")", "{", "$", "error", "=", "$", "prepared", "->", "errorInfo", "(", ")", ";", "throw", "new", "Exception", "(", "\"The delete query failed (table '\"", ".", "$", "this", "->", "getDbPrefix", "(", ")", ".", "$", "this", "->", "_item", "->", "getDbContainer", "(", ")", ".", "\"') with message '\"", ".", "$", "error", "[", "2", "]", ".", "\"'\"", ")", ";", "}", "if", "(", "$", "pWithChilds", ")", "{", "$", "this", "->", "_item", "->", "removeJoinFromAllChilds", "(", ")", ";", "}", "if", "(", "Agl", "::", "app", "(", ")", "->", "isDebugMode", "(", ")", ")", "{", "Agl", "::", "app", "(", ")", "->", "getDb", "(", ")", "->", "incrementCounter", "(", ")", ";", "}", "return", "$", "prepared", "->", "rowCount", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "return", "true", ";", "}" ]
Commit the deletion to Mysql and check the query result. @param bool $pWithChilds Delete also all item's childs in other collections @return int Number of affected rows
[ "Commit", "the", "deletion", "to", "Mysql", "and", "check", "the", "query", "result", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Query/Delete.php#L29-L63
2,555
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.set
public function set($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->set($key, $value); } else { $this->setForPeriod($key, $value, $period); } }
php
public function set($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->set($key, $value); } else { $this->setForPeriod($key, $value, $period); } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "\\", "DatePeriod", "$", "period", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "period", ")", ")", "{", "$", "this", "->", "repository", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "setForPeriod", "(", "$", "key", ",", "$", "value", ",", "$", "period", ")", ";", "}", "}" ]
Set value for a key. @param string $key Counter key. @param float|int $value Value to set. @param \DatePeriod $period Date period. @return void
[ "Set", "value", "for", "a", "key", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L38-L45
2,556
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.get
public function get($key, \DatePeriod $period = null) { if (is_null($period)) { return new Value($this->repository->get($key)); } return $this->getForPeriod($key, $period); }
php
public function get($key, \DatePeriod $period = null) { if (is_null($period)) { return new Value($this->repository->get($key)); } return $this->getForPeriod($key, $period); }
[ "public", "function", "get", "(", "$", "key", ",", "\\", "DatePeriod", "$", "period", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "period", ")", ")", "{", "return", "new", "Value", "(", "$", "this", "->", "repository", "->", "get", "(", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "getForPeriod", "(", "$", "key", ",", "$", "period", ")", ";", "}" ]
Get value for a key. @param string $key Counter key. @param \DatePeriod $period Date period. @return \Krucas\Counter\Contracts\Value|array
[ "Get", "value", "for", "a", "key", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L73-L80
2,557
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.getForPeriod
protected function getForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) { return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0])); } $values = array(); /** @var \Krucas\Counter\DateRange $range */ foreach ($ranges as $range) { $values[] = new RangeValue( $range, $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate()) ); } return $values; } return null; }
php
protected function getForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) { return new DateValue($ranges[0], $this->repository->getFor($key, $ranges[0])); } $values = array(); /** @var \Krucas\Counter\DateRange $range */ foreach ($ranges as $range) { $values[] = new RangeValue( $range, $this->repository->getForRange($key, $range->getStartDate(), $range->getEndDate()) ); } return $values; } return null; }
[ "protected", "function", "getForPeriod", "(", "$", "key", ",", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "$", "this", "->", "getRanges", "(", "$", "period", ")", ";", "if", "(", "count", "(", "$", "ranges", ")", ">", "0", ")", "{", "if", "(", "count", "(", "$", "ranges", ")", "==", "1", "&&", "!", "(", "$", "ranges", "[", "0", "]", "instanceof", "DateRange", ")", ")", "{", "return", "new", "DateValue", "(", "$", "ranges", "[", "0", "]", ",", "$", "this", "->", "repository", "->", "getFor", "(", "$", "key", ",", "$", "ranges", "[", "0", "]", ")", ")", ";", "}", "$", "values", "=", "array", "(", ")", ";", "/** @var \\Krucas\\Counter\\DateRange $range */", "foreach", "(", "$", "ranges", "as", "$", "range", ")", "{", "$", "values", "[", "]", "=", "new", "RangeValue", "(", "$", "range", ",", "$", "this", "->", "repository", "->", "getForRange", "(", "$", "key", ",", "$", "range", "->", "getStartDate", "(", ")", ",", "$", "range", "->", "getEndDate", "(", ")", ")", ")", ";", "}", "return", "$", "values", ";", "}", "return", "null", ";", "}" ]
Return value for a given period. @param string $key Counter key. @param \DatePeriod $period Date period. @return \Krucas\Counter\Contracts\Value|array|null
[ "Return", "value", "for", "a", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L89-L112
2,558
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.has
public function has($key, \DatePeriod $period = null) { if (is_null($period)) { return new Exists($this->repository->has($key)); } return $this->hasForPeriod($key, $period); }
php
public function has($key, \DatePeriod $period = null) { if (is_null($period)) { return new Exists($this->repository->has($key)); } return $this->hasForPeriod($key, $period); }
[ "public", "function", "has", "(", "$", "key", ",", "\\", "DatePeriod", "$", "period", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "period", ")", ")", "{", "return", "new", "Exists", "(", "$", "this", "->", "repository", "->", "has", "(", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "hasForPeriod", "(", "$", "key", ",", "$", "period", ")", ";", "}" ]
Determine if value exists. @param string $key Counter key. @param \DatePeriod $period Date period. @return \Krucas\Counter\Contracts\Exists|array
[ "Determine", "if", "value", "exists", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L121-L128
2,559
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.hasForPeriod
protected function hasForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) { return new DateExists($ranges[0], $this->repository->hasFor($key, $ranges[0])); } $values = array(); /** @var \Krucas\Counter\DateRange $range */ foreach ($ranges as $range) { $values[] = new RangeExists( $range, $this->repository->hasForRange($key, $range->getStartDate(), $range->getEndDate()) ); } return $values; } return new Exists(false); }
php
protected function hasForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { if (count($ranges) == 1 && !($ranges[0] instanceof DateRange)) { return new DateExists($ranges[0], $this->repository->hasFor($key, $ranges[0])); } $values = array(); /** @var \Krucas\Counter\DateRange $range */ foreach ($ranges as $range) { $values[] = new RangeExists( $range, $this->repository->hasForRange($key, $range->getStartDate(), $range->getEndDate()) ); } return $values; } return new Exists(false); }
[ "protected", "function", "hasForPeriod", "(", "$", "key", ",", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "$", "this", "->", "getRanges", "(", "$", "period", ")", ";", "if", "(", "count", "(", "$", "ranges", ")", ">", "0", ")", "{", "if", "(", "count", "(", "$", "ranges", ")", "==", "1", "&&", "!", "(", "$", "ranges", "[", "0", "]", "instanceof", "DateRange", ")", ")", "{", "return", "new", "DateExists", "(", "$", "ranges", "[", "0", "]", ",", "$", "this", "->", "repository", "->", "hasFor", "(", "$", "key", ",", "$", "ranges", "[", "0", "]", ")", ")", ";", "}", "$", "values", "=", "array", "(", ")", ";", "/** @var \\Krucas\\Counter\\DateRange $range */", "foreach", "(", "$", "ranges", "as", "$", "range", ")", "{", "$", "values", "[", "]", "=", "new", "RangeExists", "(", "$", "range", ",", "$", "this", "->", "repository", "->", "hasForRange", "(", "$", "key", ",", "$", "range", "->", "getStartDate", "(", ")", ",", "$", "range", "->", "getEndDate", "(", ")", ")", ")", ";", "}", "return", "$", "values", ";", "}", "return", "new", "Exists", "(", "false", ")", ";", "}" ]
Determine if value exists for given period. @param string $key Counter key. @param \DatePeriod $period Date period. @return \Krucas\Counter\Contracts\Exists|array
[ "Determine", "if", "value", "exists", "for", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L137-L160
2,560
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.increment
public function increment($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->increment($key, $value); } else { $this->incrementForPeriod($key, $value, $period); } }
php
public function increment($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->increment($key, $value); } else { $this->incrementForPeriod($key, $value, $period); } }
[ "public", "function", "increment", "(", "$", "key", ",", "$", "value", ",", "\\", "DatePeriod", "$", "period", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "period", ")", ")", "{", "$", "this", "->", "repository", "->", "increment", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "incrementForPeriod", "(", "$", "key", ",", "$", "value", ",", "$", "period", ")", ";", "}", "}" ]
Increment value. @param string $key Counter key. @param float|int $value Increment by value. @param \DatePeriod $period Date period. @return void
[ "Increment", "value", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L170-L177
2,561
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.incrementForPeriod
protected function incrementForPeriod($key, $value, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->incrementForRange($key, $range->getStartDate(), $range->getEndDate(), $value) : $this->repository->incrementFor($key, $range, $value); } } }
php
protected function incrementForPeriod($key, $value, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->incrementForRange($key, $range->getStartDate(), $range->getEndDate(), $value) : $this->repository->incrementFor($key, $range, $value); } } }
[ "protected", "function", "incrementForPeriod", "(", "$", "key", ",", "$", "value", ",", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "$", "this", "->", "getRanges", "(", "$", "period", ")", ";", "if", "(", "count", "(", "$", "ranges", ")", ">", "0", ")", "{", "foreach", "(", "$", "ranges", "as", "$", "range", ")", "{", "$", "range", "instanceof", "DateRange", "?", "$", "this", "->", "repository", "->", "incrementForRange", "(", "$", "key", ",", "$", "range", "->", "getStartDate", "(", ")", ",", "$", "range", "->", "getEndDate", "(", ")", ",", "$", "value", ")", ":", "$", "this", "->", "repository", "->", "incrementFor", "(", "$", "key", ",", "$", "range", ",", "$", "value", ")", ";", "}", "}", "}" ]
Increment value for a given period. @param string $key Counter key. @param float|int $value Increment by value. @param \DatePeriod $period Date period. @return void
[ "Increment", "value", "for", "a", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L187-L198
2,562
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.decrement
public function decrement($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->decrement($key, $value); } else { $this->decrementForPeriod($key, $value, $period); } }
php
public function decrement($key, $value, \DatePeriod $period = null) { if (is_null($period)) { $this->repository->decrement($key, $value); } else { $this->decrementForPeriod($key, $value, $period); } }
[ "public", "function", "decrement", "(", "$", "key", ",", "$", "value", ",", "\\", "DatePeriod", "$", "period", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "period", ")", ")", "{", "$", "this", "->", "repository", "->", "decrement", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "decrementForPeriod", "(", "$", "key", ",", "$", "value", ",", "$", "period", ")", ";", "}", "}" ]
Decrement value. @param string $key Counter key. @param float|int $value Decrement by value. @param \DatePeriod $period Date period. @return void
[ "Decrement", "value", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L208-L215
2,563
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.decrementForPeriod
protected function decrementForPeriod($key, $value, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->decrementForRange($key, $range->getStartDate(), $range->getEndDate(), $value) : $this->repository->decrementFor($key, $range, $value); } } }
php
protected function decrementForPeriod($key, $value, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->decrementForRange($key, $range->getStartDate(), $range->getEndDate(), $value) : $this->repository->decrementFor($key, $range, $value); } } }
[ "protected", "function", "decrementForPeriod", "(", "$", "key", ",", "$", "value", ",", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "$", "this", "->", "getRanges", "(", "$", "period", ")", ";", "if", "(", "count", "(", "$", "ranges", ")", ">", "0", ")", "{", "foreach", "(", "$", "ranges", "as", "$", "range", ")", "{", "$", "range", "instanceof", "DateRange", "?", "$", "this", "->", "repository", "->", "decrementForRange", "(", "$", "key", ",", "$", "range", "->", "getStartDate", "(", ")", ",", "$", "range", "->", "getEndDate", "(", ")", ",", "$", "value", ")", ":", "$", "this", "->", "repository", "->", "decrementFor", "(", "$", "key", ",", "$", "range", ",", "$", "value", ")", ";", "}", "}", "}" ]
Decrement value for a given period. @param string $key Counter key. @param float|int $value Decrement by value. @param \DatePeriod $period Date period. @return void
[ "Decrement", "value", "for", "a", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L225-L236
2,564
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.removeForPeriod
protected function removeForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->removeForRange($key, $range->getStartDate(), $range->getEndDate()) : $this->repository->removeFor($key, $range); } } }
php
protected function removeForPeriod($key, \DatePeriod $period) { $ranges = $this->getRanges($period); if (count($ranges) > 0) { foreach ($ranges as $range) { $range instanceof DateRange ? $this->repository->removeForRange($key, $range->getStartDate(), $range->getEndDate()) : $this->repository->removeFor($key, $range); } } }
[ "protected", "function", "removeForPeriod", "(", "$", "key", ",", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "$", "this", "->", "getRanges", "(", "$", "period", ")", ";", "if", "(", "count", "(", "$", "ranges", ")", ">", "0", ")", "{", "foreach", "(", "$", "ranges", "as", "$", "range", ")", "{", "$", "range", "instanceof", "DateRange", "?", "$", "this", "->", "repository", "->", "removeForRange", "(", "$", "key", ",", "$", "range", "->", "getStartDate", "(", ")", ",", "$", "range", "->", "getEndDate", "(", ")", ")", ":", "$", "this", "->", "repository", "->", "removeFor", "(", "$", "key", ",", "$", "range", ")", ";", "}", "}", "}" ]
Remove value for a given period. @param string $key Counter key. @param \DatePeriod $period Date period. @return void
[ "Remove", "value", "for", "a", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L261-L272
2,565
edvinaskrucas/counter
src/Krucas/Counter/Counter.php
Counter.getRanges
protected function getRanges(\DatePeriod $period) { $ranges = array(); $start = null; $end = null; $single = true; foreach ($period as $i => $date) { // Set single date $ranges[$i] = $date; // This is interval, so set it. if ($i > 0) { $ranges[$i - 1] = new DateRange($ranges[$i - 1], $date); $single = false; } } // Ranges are stored, so we don't need las element if (!$single) { array_pop($ranges); } return $ranges; }
php
protected function getRanges(\DatePeriod $period) { $ranges = array(); $start = null; $end = null; $single = true; foreach ($period as $i => $date) { // Set single date $ranges[$i] = $date; // This is interval, so set it. if ($i > 0) { $ranges[$i - 1] = new DateRange($ranges[$i - 1], $date); $single = false; } } // Ranges are stored, so we don't need las element if (!$single) { array_pop($ranges); } return $ranges; }
[ "protected", "function", "getRanges", "(", "\\", "DatePeriod", "$", "period", ")", "{", "$", "ranges", "=", "array", "(", ")", ";", "$", "start", "=", "null", ";", "$", "end", "=", "null", ";", "$", "single", "=", "true", ";", "foreach", "(", "$", "period", "as", "$", "i", "=>", "$", "date", ")", "{", "// Set single date", "$", "ranges", "[", "$", "i", "]", "=", "$", "date", ";", "// This is interval, so set it.", "if", "(", "$", "i", ">", "0", ")", "{", "$", "ranges", "[", "$", "i", "-", "1", "]", "=", "new", "DateRange", "(", "$", "ranges", "[", "$", "i", "-", "1", "]", ",", "$", "date", ")", ";", "$", "single", "=", "false", ";", "}", "}", "// Ranges are stored, so we don't need las element", "if", "(", "!", "$", "single", ")", "{", "array_pop", "(", "$", "ranges", ")", ";", "}", "return", "$", "ranges", ";", "}" ]
Generate date ranges from given period. @param \DatePeriod $period Date period. @return array
[ "Generate", "date", "ranges", "from", "given", "period", "." ]
cf61963b9f90e2801d89f797f73e53edcc67cc19
https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/Counter.php#L280-L305
2,566
matryoshka-model/service-api
library/Client/HttpApi.php
HttpApi.prepareFileUploadRequest
public function prepareFileUploadRequest(array $files, $relativePath = null, array $data = [], array $query = []) { $request = $this->prepareRequest('POST', $relativePath, [], $query); $request->getHeaders()->removeHeader($request->getHeaders()->get('Content-Type')); $this->httpClient->setRequest($request); foreach ($files as $formName => $filePath) { $this->httpClient->setFileUpload($filePath, $formName); if (isset($data[$formName])) { $file = $request->getFiles()->get($filePath, null); if ($file) { // If present, override the filename $file['filename'] = $data[$formName]; $request->getFiles()->set($filePath, $file); } unset($data[$formName]); } } $request->getPost()->fromArray($data); return $request; }
php
public function prepareFileUploadRequest(array $files, $relativePath = null, array $data = [], array $query = []) { $request = $this->prepareRequest('POST', $relativePath, [], $query); $request->getHeaders()->removeHeader($request->getHeaders()->get('Content-Type')); $this->httpClient->setRequest($request); foreach ($files as $formName => $filePath) { $this->httpClient->setFileUpload($filePath, $formName); if (isset($data[$formName])) { $file = $request->getFiles()->get($filePath, null); if ($file) { // If present, override the filename $file['filename'] = $data[$formName]; $request->getFiles()->set($filePath, $file); } unset($data[$formName]); } } $request->getPost()->fromArray($data); return $request; }
[ "public", "function", "prepareFileUploadRequest", "(", "array", "$", "files", ",", "$", "relativePath", "=", "null", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "query", "=", "[", "]", ")", "{", "$", "request", "=", "$", "this", "->", "prepareRequest", "(", "'POST'", ",", "$", "relativePath", ",", "[", "]", ",", "$", "query", ")", ";", "$", "request", "->", "getHeaders", "(", ")", "->", "removeHeader", "(", "$", "request", "->", "getHeaders", "(", ")", "->", "get", "(", "'Content-Type'", ")", ")", ";", "$", "this", "->", "httpClient", "->", "setRequest", "(", "$", "request", ")", ";", "foreach", "(", "$", "files", "as", "$", "formName", "=>", "$", "filePath", ")", "{", "$", "this", "->", "httpClient", "->", "setFileUpload", "(", "$", "filePath", ",", "$", "formName", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "formName", "]", ")", ")", "{", "$", "file", "=", "$", "request", "->", "getFiles", "(", ")", "->", "get", "(", "$", "filePath", ",", "null", ")", ";", "if", "(", "$", "file", ")", "{", "// If present, override the filename", "$", "file", "[", "'filename'", "]", "=", "$", "data", "[", "$", "formName", "]", ";", "$", "request", "->", "getFiles", "(", ")", "->", "set", "(", "$", "filePath", ",", "$", "file", ")", ";", "}", "unset", "(", "$", "data", "[", "$", "formName", "]", ")", ";", "}", "}", "$", "request", "->", "getPost", "(", ")", "->", "fromArray", "(", "$", "data", ")", ";", "return", "$", "request", ";", "}" ]
Prepare a POST request for uploading files The request method will be set to POST and multipart/form-data will be used as content type, ignoring the current request format. $files is treated as: [ name => localFilePath, ... ] $data will be used for other data data without the filename segment. Each localFilePath will be read and sent. Will try to guess the content type using mime_content_type(). By default, the basename of localFilePath will be sent as filename segment, if a 'name' is also present in $data then the value of $data[name] will be used as filename segment. @param array $files @param string $relativePath @param array $data @param array $query @return \Zend\Http\Request
[ "Prepare", "a", "POST", "request", "for", "uploading", "files" ]
c188baa8bf4ec8827fde2a9ea1851880778c32c9
https://github.com/matryoshka-model/service-api/blob/c188baa8bf4ec8827fde2a9ea1851880778c32c9/library/Client/HttpApi.php#L131-L156
2,567
SocietyCMS/Core
Providers/CoreServiceProvider.php
CoreServiceProvider.registerMiddleware
public function registerMiddleware(Router $router) { foreach ($this->middleware as $module => $middlewares) { foreach ($middlewares as $name => $middleware) { $class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}"; $router->middleware($name, $class); } } }
php
public function registerMiddleware(Router $router) { foreach ($this->middleware as $module => $middlewares) { foreach ($middlewares as $name => $middleware) { $class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}"; $router->middleware($name, $class); } } }
[ "public", "function", "registerMiddleware", "(", "Router", "$", "router", ")", "{", "foreach", "(", "$", "this", "->", "middleware", "as", "$", "module", "=>", "$", "middlewares", ")", "{", "foreach", "(", "$", "middlewares", "as", "$", "name", "=>", "$", "middleware", ")", "{", "$", "class", "=", "\"Modules\\\\{$module}\\\\Http\\\\Middleware\\\\{$middleware}\"", ";", "$", "router", "->", "middleware", "(", "$", "name", ",", "$", "class", ")", ";", "}", "}", "}" ]
Register the filters. @param Router $router @return void
[ "Register", "the", "filters", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/CoreServiceProvider.php#L66-L75
2,568
SocietyCMS/Core
Providers/CoreServiceProvider.php
CoreServiceProvider.registerModulePermissions
private function registerModulePermissions() { foreach ($this->app['modules']->enabled() as $module) { if ($this->app['society.isInstalled']) { $permissionManager = new PermissionManager(); $permissionManager->registerDefault($module); } } }
php
private function registerModulePermissions() { foreach ($this->app['modules']->enabled() as $module) { if ($this->app['society.isInstalled']) { $permissionManager = new PermissionManager(); $permissionManager->registerDefault($module); } } }
[ "private", "function", "registerModulePermissions", "(", ")", "{", "foreach", "(", "$", "this", "->", "app", "[", "'modules'", "]", "->", "enabled", "(", ")", "as", "$", "module", ")", "{", "if", "(", "$", "this", "->", "app", "[", "'society.isInstalled'", "]", ")", "{", "$", "permissionManager", "=", "new", "PermissionManager", "(", ")", ";", "$", "permissionManager", "->", "registerDefault", "(", "$", "module", ")", ";", "}", "}", "}" ]
Register the modules dependencies.
[ "Register", "the", "modules", "dependencies", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/CoreServiceProvider.php#L80-L88
2,569
SocietyCMS/Core
Providers/CoreServiceProvider.php
CoreServiceProvider.registerBindings
private function registerBindings() { $this->app->bind('society.isInstalled', function ($app) { return file_exists(base_path('.env')) && file_exists(storage_path('app/installed')) && Schema::hasTable('migrations'); }); }
php
private function registerBindings() { $this->app->bind('society.isInstalled', function ($app) { return file_exists(base_path('.env')) && file_exists(storage_path('app/installed')) && Schema::hasTable('migrations'); }); }
[ "private", "function", "registerBindings", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'society.isInstalled'", ",", "function", "(", "$", "app", ")", "{", "return", "file_exists", "(", "base_path", "(", "'.env'", ")", ")", "&&", "file_exists", "(", "storage_path", "(", "'app/installed'", ")", ")", "&&", "Schema", "::", "hasTable", "(", "'migrations'", ")", ";", "}", ")", ";", "}" ]
Register general App-Bindings.
[ "Register", "general", "App", "-", "Bindings", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Providers/CoreServiceProvider.php#L93-L101
2,570
infinity-next/eightdown
src/Traits/ParsedownDirectional.php
ParsedownDirectional.unmarkedText
protected function unmarkedText($text) { $newText = ""; if ($this->breaksEnabled) { $parts = mb_split('[ ]*\n', $text); } else { $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\n', $text); } foreach ($parts as $index => &$part) { if ($index > 0) { $newText .= "<br />\n"; } // Remove trailing spaces. $part = mb_ereg_replace('/[ ]*\n/', "\n", $part); // Determine directon $ltr = $this->getLtrStrLen($part); $rtl = $this->getRtlStrLen($part); $dir = null; if ($this->isLtr() && $rtl > 0 && $rtl > $ltr) { $dir = "rtl"; } else if ($this->isRtl() && $ltr > 0 && $ltr > $rtl) { $dir = "ltr"; } if (!is_null($dir)) { $newText .= "<div dir=\"{$dir}\">{$part}</div>"; } else { $newText .= $part; } } return $newText; }
php
protected function unmarkedText($text) { $newText = ""; if ($this->breaksEnabled) { $parts = mb_split('[ ]*\n', $text); } else { $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\n', $text); } foreach ($parts as $index => &$part) { if ($index > 0) { $newText .= "<br />\n"; } // Remove trailing spaces. $part = mb_ereg_replace('/[ ]*\n/', "\n", $part); // Determine directon $ltr = $this->getLtrStrLen($part); $rtl = $this->getRtlStrLen($part); $dir = null; if ($this->isLtr() && $rtl > 0 && $rtl > $ltr) { $dir = "rtl"; } else if ($this->isRtl() && $ltr > 0 && $ltr > $rtl) { $dir = "ltr"; } if (!is_null($dir)) { $newText .= "<div dir=\"{$dir}\">{$part}</div>"; } else { $newText .= $part; } } return $newText; }
[ "protected", "function", "unmarkedText", "(", "$", "text", ")", "{", "$", "newText", "=", "\"\"", ";", "if", "(", "$", "this", "->", "breaksEnabled", ")", "{", "$", "parts", "=", "mb_split", "(", "'[ ]*\\n'", ",", "$", "text", ")", ";", "}", "else", "{", "$", "parts", "=", "mb_split", "(", "'(?:[ ][ ]+|[ ]*\\\\\\\\)\\n'", ",", "$", "text", ")", ";", "}", "foreach", "(", "$", "parts", "as", "$", "index", "=>", "&", "$", "part", ")", "{", "if", "(", "$", "index", ">", "0", ")", "{", "$", "newText", ".=", "\"<br />\\n\"", ";", "}", "// Remove trailing spaces.", "$", "part", "=", "mb_ereg_replace", "(", "'/[ ]*\\n/'", ",", "\"\\n\"", ",", "$", "part", ")", ";", "// Determine directon", "$", "ltr", "=", "$", "this", "->", "getLtrStrLen", "(", "$", "part", ")", ";", "$", "rtl", "=", "$", "this", "->", "getRtlStrLen", "(", "$", "part", ")", ";", "$", "dir", "=", "null", ";", "if", "(", "$", "this", "->", "isLtr", "(", ")", "&&", "$", "rtl", ">", "0", "&&", "$", "rtl", ">", "$", "ltr", ")", "{", "$", "dir", "=", "\"rtl\"", ";", "}", "else", "if", "(", "$", "this", "->", "isRtl", "(", ")", "&&", "$", "ltr", ">", "0", "&&", "$", "ltr", ">", "$", "rtl", ")", "{", "$", "dir", "=", "\"ltr\"", ";", "}", "if", "(", "!", "is_null", "(", "$", "dir", ")", ")", "{", "$", "newText", ".=", "\"<div dir=\\\"{$dir}\\\">{$part}</div>\"", ";", "}", "else", "{", "$", "newText", ".=", "$", "part", ";", "}", "}", "return", "$", "newText", ";", "}" ]
Inject span tags for each line to indicate direction. @param string $text Single line's worth of text. @return string
[ "Inject", "span", "tags", "for", "each", "line", "to", "indicate", "direction", "." ]
e3ec0b573110a244880d09f1c92f1e932632733b
https://github.com/infinity-next/eightdown/blob/e3ec0b573110a244880d09f1c92f1e932632733b/src/Traits/ParsedownDirectional.php#L89-L137
2,571
0x20h/phloppy
src/Client/Queue.php
Queue.scan
public function scan($count = 50, $min = 0, $max = 0, $rate = 0) { $iterator = new QScanIterator($this->stream, $this->log); $iterator->setCount($count) ->setMin($min) ->setMax($max) ->setRate($rate); return $iterator; }
php
public function scan($count = 50, $min = 0, $max = 0, $rate = 0) { $iterator = new QScanIterator($this->stream, $this->log); $iterator->setCount($count) ->setMin($min) ->setMax($max) ->setRate($rate); return $iterator; }
[ "public", "function", "scan", "(", "$", "count", "=", "50", ",", "$", "min", "=", "0", ",", "$", "max", "=", "0", ",", "$", "rate", "=", "0", ")", "{", "$", "iterator", "=", "new", "QScanIterator", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "log", ")", ";", "$", "iterator", "->", "setCount", "(", "$", "count", ")", "->", "setMin", "(", "$", "min", ")", "->", "setMax", "(", "$", "max", ")", "->", "setRate", "(", "$", "rate", ")", ";", "return", "$", "iterator", ";", "}" ]
Scan all existing queues. Options may be used to filter the scan results. @param int $count Return count elements per call. A count of 0 implies returning all elements at once. @param int $min Filter queues with at least min elements. @param int $max Filter queues with at most max elements. @param int $rate Filter queues by job import rate. @return Iterator
[ "Scan", "all", "existing", "queues", "." ]
d917f0578360395899bd583724046d36ac459535
https://github.com/0x20h/phloppy/blob/d917f0578360395899bd583724046d36ac459535/src/Client/Queue.php#L52-L61
2,572
thecodingmachine/utils.log.errorlog_logger
src/Mouf/Utils/Log/ErrorLogLogger.php
ErrorLogLogger.getTextBackTrace
static private function getTextBackTrace($backtrace) { $str = ''; foreach ($backtrace as $step) { if ($step['function']!='getTextBackTrace' && $step['function']!='handle_error') { if (isset($step['file']) && isset($step['line'])) { $str .= "In ".$step['file'] . " at line ".$step['line'].": "; } if (isset($step['class']) && isset($step['type']) && isset($step['function'])) { $str .= $step['class'].$step['type'].$step['function'].'('; } if (is_array($step['args'])) { $drawn = false; $params = ''; foreach ( $step['args'] as $param) { $params .= self::getPhpVariableAsText($param); //$params .= var_export($param, true); $params .= ', '; $drawn = true; } $str .= $params; if ($drawn == true) $str = substr($str, 0, strlen($str)-2); } $str .= ')'; $str .= "\n"; } } return $str; }
php
static private function getTextBackTrace($backtrace) { $str = ''; foreach ($backtrace as $step) { if ($step['function']!='getTextBackTrace' && $step['function']!='handle_error') { if (isset($step['file']) && isset($step['line'])) { $str .= "In ".$step['file'] . " at line ".$step['line'].": "; } if (isset($step['class']) && isset($step['type']) && isset($step['function'])) { $str .= $step['class'].$step['type'].$step['function'].'('; } if (is_array($step['args'])) { $drawn = false; $params = ''; foreach ( $step['args'] as $param) { $params .= self::getPhpVariableAsText($param); //$params .= var_export($param, true); $params .= ', '; $drawn = true; } $str .= $params; if ($drawn == true) $str = substr($str, 0, strlen($str)-2); } $str .= ')'; $str .= "\n"; } } return $str; }
[ "static", "private", "function", "getTextBackTrace", "(", "$", "backtrace", ")", "{", "$", "str", "=", "''", ";", "foreach", "(", "$", "backtrace", "as", "$", "step", ")", "{", "if", "(", "$", "step", "[", "'function'", "]", "!=", "'getTextBackTrace'", "&&", "$", "step", "[", "'function'", "]", "!=", "'handle_error'", ")", "{", "if", "(", "isset", "(", "$", "step", "[", "'file'", "]", ")", "&&", "isset", "(", "$", "step", "[", "'line'", "]", ")", ")", "{", "$", "str", ".=", "\"In \"", ".", "$", "step", "[", "'file'", "]", ".", "\" at line \"", ".", "$", "step", "[", "'line'", "]", ".", "\": \"", ";", "}", "if", "(", "isset", "(", "$", "step", "[", "'class'", "]", ")", "&&", "isset", "(", "$", "step", "[", "'type'", "]", ")", "&&", "isset", "(", "$", "step", "[", "'function'", "]", ")", ")", "{", "$", "str", ".=", "$", "step", "[", "'class'", "]", ".", "$", "step", "[", "'type'", "]", ".", "$", "step", "[", "'function'", "]", ".", "'('", ";", "}", "if", "(", "is_array", "(", "$", "step", "[", "'args'", "]", ")", ")", "{", "$", "drawn", "=", "false", ";", "$", "params", "=", "''", ";", "foreach", "(", "$", "step", "[", "'args'", "]", "as", "$", "param", ")", "{", "$", "params", ".=", "self", "::", "getPhpVariableAsText", "(", "$", "param", ")", ";", "//$params .= var_export($param, true);\r", "$", "params", ".=", "', '", ";", "$", "drawn", "=", "true", ";", "}", "$", "str", ".=", "$", "params", ";", "if", "(", "$", "drawn", "==", "true", ")", "$", "str", "=", "substr", "(", "$", "str", ",", "0", ",", "strlen", "(", "$", "str", ")", "-", "2", ")", ";", "}", "$", "str", ".=", "')'", ";", "$", "str", ".=", "\"\\n\"", ";", "}", "}", "return", "$", "str", ";", "}" ]
Returns the Exception Backtrace as a text string. @param unknown_type $backtrace @return unknown
[ "Returns", "the", "Exception", "Backtrace", "as", "a", "text", "string", "." ]
352ad3733757685961818c012187945a4c9d04df
https://github.com/thecodingmachine/utils.log.errorlog_logger/blob/352ad3733757685961818c012187945a4c9d04df/src/Mouf/Utils/Log/ErrorLogLogger.php#L109-L142
2,573
tigron/skeleton-i18n
lib/Skeleton/I18n/Translation.php
Translation.add_to_po
private function add_to_po($string) { $this->strings[$string] = ''; $current_strings = Util::load(Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po'); $untranslated = [$string => '']; $strings = array_merge($untranslated, $current_strings); ksort($strings); Util::save(Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po', $this->application_name, $this->language, $strings); }
php
private function add_to_po($string) { $this->strings[$string] = ''; $current_strings = Util::load(Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po'); $untranslated = [$string => '']; $strings = array_merge($untranslated, $current_strings); ksort($strings); Util::save(Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po', $this->application_name, $this->language, $strings); }
[ "private", "function", "add_to_po", "(", "$", "string", ")", "{", "$", "this", "->", "strings", "[", "$", "string", "]", "=", "''", ";", "$", "current_strings", "=", "Util", "::", "load", "(", "Config", "::", "$", "po_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.po'", ")", ";", "$", "untranslated", "=", "[", "$", "string", "=>", "''", "]", ";", "$", "strings", "=", "array_merge", "(", "$", "untranslated", ",", "$", "current_strings", ")", ";", "ksort", "(", "$", "strings", ")", ";", "Util", "::", "save", "(", "Config", "::", "$", "po_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.po'", ",", "$", "this", "->", "application_name", ",", "$", "this", "->", "language", ",", "$", "strings", ")", ";", "}" ]
Add a string to the po file @access public @param string $string
[ "Add", "a", "string", "to", "the", "po", "file" ]
b1523e69ec8674b9d9359045ff0ee4dfde66f9e6
https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Translation.php#L99-L108
2,574
tigron/skeleton-i18n
lib/Skeleton/I18n/Translation.php
Translation.reload_po_file
private function reload_po_file() { $po_files = []; $po_files[] = Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po'; $packages = \Skeleton\Core\Package::get_all(); foreach ($packages as $package) { if (file_exists(Config::$po_directory . '/' . $this->language->name_short . '/package/' . $package->name . '.po')) { $po_files[] = Config::$po_directory . '/' . $this->language->name_short . '/package/' . $package->name . '.po'; } } $array_modified = 0; if (file_exists(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php')) { $array_modified = filemtime(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php'); } $po_file_modified = null; foreach ($po_files as $po_file) { if (!file_exists($po_file)) { continue; } if ($po_file_modified === null) { $po_file_modified = filemtime($po_file); } if (filemtime($po_file) > $po_file_modified) { $po_file_modified = filemtime($po_file); } } if ($array_modified >= $po_file_modified) { return; } $po_strings = []; foreach (array_reverse($po_files) as $po_file) { $strings = Util::load($po_file); foreach ($strings as $key => $value) { if (!isset($po_strings[$key])) { $po_strings[$key] = $value; } elseif ($value != '') { $po_strings[$key] = $value; } else { continue; } } } if (!file_exists(Config::$cache_directory . '/' . $this->language->name_short)) { mkdir(Config::$cache_directory . '/' . $this->language->name_short, 0755, true); } file_put_contents(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php', '<?php $strings = ' . var_export($po_strings, true) . ';'); }
php
private function reload_po_file() { $po_files = []; $po_files[] = Config::$po_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.po'; $packages = \Skeleton\Core\Package::get_all(); foreach ($packages as $package) { if (file_exists(Config::$po_directory . '/' . $this->language->name_short . '/package/' . $package->name . '.po')) { $po_files[] = Config::$po_directory . '/' . $this->language->name_short . '/package/' . $package->name . '.po'; } } $array_modified = 0; if (file_exists(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php')) { $array_modified = filemtime(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php'); } $po_file_modified = null; foreach ($po_files as $po_file) { if (!file_exists($po_file)) { continue; } if ($po_file_modified === null) { $po_file_modified = filemtime($po_file); } if (filemtime($po_file) > $po_file_modified) { $po_file_modified = filemtime($po_file); } } if ($array_modified >= $po_file_modified) { return; } $po_strings = []; foreach (array_reverse($po_files) as $po_file) { $strings = Util::load($po_file); foreach ($strings as $key => $value) { if (!isset($po_strings[$key])) { $po_strings[$key] = $value; } elseif ($value != '') { $po_strings[$key] = $value; } else { continue; } } } if (!file_exists(Config::$cache_directory . '/' . $this->language->name_short)) { mkdir(Config::$cache_directory . '/' . $this->language->name_short, 0755, true); } file_put_contents(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php', '<?php $strings = ' . var_export($po_strings, true) . ';'); }
[ "private", "function", "reload_po_file", "(", ")", "{", "$", "po_files", "=", "[", "]", ";", "$", "po_files", "[", "]", "=", "Config", "::", "$", "po_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.po'", ";", "$", "packages", "=", "\\", "Skeleton", "\\", "Core", "\\", "Package", "::", "get_all", "(", ")", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "if", "(", "file_exists", "(", "Config", "::", "$", "po_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/package/'", ".", "$", "package", "->", "name", ".", "'.po'", ")", ")", "{", "$", "po_files", "[", "]", "=", "Config", "::", "$", "po_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/package/'", ".", "$", "package", "->", "name", ".", "'.po'", ";", "}", "}", "$", "array_modified", "=", "0", ";", "if", "(", "file_exists", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.php'", ")", ")", "{", "$", "array_modified", "=", "filemtime", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.php'", ")", ";", "}", "$", "po_file_modified", "=", "null", ";", "foreach", "(", "$", "po_files", "as", "$", "po_file", ")", "{", "if", "(", "!", "file_exists", "(", "$", "po_file", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "po_file_modified", "===", "null", ")", "{", "$", "po_file_modified", "=", "filemtime", "(", "$", "po_file", ")", ";", "}", "if", "(", "filemtime", "(", "$", "po_file", ")", ">", "$", "po_file_modified", ")", "{", "$", "po_file_modified", "=", "filemtime", "(", "$", "po_file", ")", ";", "}", "}", "if", "(", "$", "array_modified", ">=", "$", "po_file_modified", ")", "{", "return", ";", "}", "$", "po_strings", "=", "[", "]", ";", "foreach", "(", "array_reverse", "(", "$", "po_files", ")", "as", "$", "po_file", ")", "{", "$", "strings", "=", "Util", "::", "load", "(", "$", "po_file", ")", ";", "foreach", "(", "$", "strings", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "po_strings", "[", "$", "key", "]", ")", ")", "{", "$", "po_strings", "[", "$", "key", "]", "=", "$", "value", ";", "}", "elseif", "(", "$", "value", "!=", "''", ")", "{", "$", "po_strings", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "continue", ";", "}", "}", "}", "if", "(", "!", "file_exists", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ")", ")", "{", "mkdir", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ",", "0755", ",", "true", ")", ";", "}", "file_put_contents", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.php'", ",", "'<?php $strings = '", ".", "var_export", "(", "$", "po_strings", ",", "true", ")", ".", "';'", ")", ";", "}" ]
Read the po files @access public
[ "Read", "the", "po", "files" ]
b1523e69ec8674b9d9359045ff0ee4dfde66f9e6
https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Translation.php#L115-L167
2,575
tigron/skeleton-i18n
lib/Skeleton/I18n/Translation.php
Translation.load_strings
private function load_strings() { if (file_exists(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php')) { require Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php'; $this->strings = $strings; } }
php
private function load_strings() { if (file_exists(Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php')) { require Config::$cache_directory . '/' . $this->language->name_short . '/' . $this->application_name . '.php'; $this->strings = $strings; } }
[ "private", "function", "load_strings", "(", ")", "{", "if", "(", "file_exists", "(", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.php'", ")", ")", "{", "require", "Config", "::", "$", "cache_directory", ".", "'/'", ".", "$", "this", "->", "language", "->", "name_short", ".", "'/'", ".", "$", "this", "->", "application_name", ".", "'.php'", ";", "$", "this", "->", "strings", "=", "$", "strings", ";", "}", "}" ]
Load the strings @access private
[ "Load", "the", "strings" ]
b1523e69ec8674b9d9359045ff0ee4dfde66f9e6
https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Translation.php#L174-L179
2,576
tigron/skeleton-i18n
lib/Skeleton/I18n/Translation.php
Translation.get
public static function get(LanguageInterface $language = null, $application_name = null) { if (!isset(self::$translation[$language->name_short]) OR self::$translation[$language->name_short]->application_name != $application_name) { self::$translation[$language->name_short] = new self($language, $application_name); } return self::$translation[$language->name_short]; }
php
public static function get(LanguageInterface $language = null, $application_name = null) { if (!isset(self::$translation[$language->name_short]) OR self::$translation[$language->name_short]->application_name != $application_name) { self::$translation[$language->name_short] = new self($language, $application_name); } return self::$translation[$language->name_short]; }
[ "public", "static", "function", "get", "(", "LanguageInterface", "$", "language", "=", "null", ",", "$", "application_name", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "translation", "[", "$", "language", "->", "name_short", "]", ")", "OR", "self", "::", "$", "translation", "[", "$", "language", "->", "name_short", "]", "->", "application_name", "!=", "$", "application_name", ")", "{", "self", "::", "$", "translation", "[", "$", "language", "->", "name_short", "]", "=", "new", "self", "(", "$", "language", ",", "$", "application_name", ")", ";", "}", "return", "self", "::", "$", "translation", "[", "$", "language", "->", "name_short", "]", ";", "}" ]
Get a translation object @access public @return Translation $translation
[ "Get", "a", "translation", "object" ]
b1523e69ec8674b9d9359045ff0ee4dfde66f9e6
https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Translation.php#L187-L193
2,577
tigron/skeleton-i18n
lib/Skeleton/I18n/Translation.php
Translation.translate_plural
public static function translate_plural($string, Translation $translation = null) { if ($translation !== null) { $translation = self::get($translation->language, $translation->application_name); } else { $translation = self::get(); } return $translation->translate_string($string); }
php
public static function translate_plural($string, Translation $translation = null) { if ($translation !== null) { $translation = self::get($translation->language, $translation->application_name); } else { $translation = self::get(); } return $translation->translate_string($string); }
[ "public", "static", "function", "translate_plural", "(", "$", "string", ",", "Translation", "$", "translation", "=", "null", ")", "{", "if", "(", "$", "translation", "!==", "null", ")", "{", "$", "translation", "=", "self", "::", "get", "(", "$", "translation", "->", "language", ",", "$", "translation", "->", "application_name", ")", ";", "}", "else", "{", "$", "translation", "=", "self", "::", "get", "(", ")", ";", "}", "return", "$", "translation", "->", "translate_string", "(", "$", "string", ")", ";", "}" ]
Translate a plural string @access public @return string $translated_string @param string $string
[ "Translate", "a", "plural", "string" ]
b1523e69ec8674b9d9359045ff0ee4dfde66f9e6
https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Translation.php#L219-L227
2,578
thecodingmachine/utils.i18n.fine.common
src/Ui/EditTranslationProxyTrait.php
EditTranslationProxyTrait.setTranslationForMessageFromService
protected function setTranslationForMessageFromService($selfEdit, $msgInstanceName, $key, $label, $language, $delete) { if ($delete) { $translationService = new InstanceProxy($msgInstanceName, $selfEdit); return $translationService->deleteMessage($key, $language); } else { $translationService = new InstanceProxy($msgInstanceName, $selfEdit); return $translationService->setMessage($key, $label, $language); } }
php
protected function setTranslationForMessageFromService($selfEdit, $msgInstanceName, $key, $label, $language, $delete) { if ($delete) { $translationService = new InstanceProxy($msgInstanceName, $selfEdit); return $translationService->deleteMessage($key, $language); } else { $translationService = new InstanceProxy($msgInstanceName, $selfEdit); return $translationService->setMessage($key, $label, $language); } }
[ "protected", "function", "setTranslationForMessageFromService", "(", "$", "selfEdit", ",", "$", "msgInstanceName", ",", "$", "key", ",", "$", "label", ",", "$", "language", ",", "$", "delete", ")", "{", "if", "(", "$", "delete", ")", "{", "$", "translationService", "=", "new", "InstanceProxy", "(", "$", "msgInstanceName", ",", "$", "selfEdit", ")", ";", "return", "$", "translationService", "->", "deleteMessage", "(", "$", "key", ",", "$", "language", ")", ";", "}", "else", "{", "$", "translationService", "=", "new", "InstanceProxy", "(", "$", "msgInstanceName", ",", "$", "selfEdit", ")", ";", "return", "$", "translationService", "->", "setMessage", "(", "$", "key", ",", "$", "label", ",", "$", "language", ")", ";", "}", "}" ]
Saves the translation for one key and one language using CURL. @param bool $selfEdit @param string $msgInstanceName @param string $key @param string $label @param string $language @param string $delete @return boolean @throws Exception
[ "Saves", "the", "translation", "for", "one", "key", "and", "one", "language", "using", "CURL", "." ]
c59327f09fb2967e8a90c05927b49da969431f15
https://github.com/thecodingmachine/utils.i18n.fine.common/blob/c59327f09fb2967e8a90c05927b49da969431f15/src/Ui/EditTranslationProxyTrait.php#L89-L100
2,579
osflab/view
Helper/Bootstrap/Grid.php
Grid.autoNewCol
public function autoNewCol(int $nbColForThisCell = 1, array $classes = [], array $attrs = []):string { !$this->autoStarted && $this->autoStart(); $src = ''; $this->status === self::STATUS_IN_CELL && $src .= $this->endCell(); $this->status === self::STATUS_OK && $src .= $this->beginContainer($this->autoFluid, $this->autoContainer, $this->autoContainerClasses); $this->status === self::STATUS_IN_CONTAINER && $src .= $this->beginRow(); if ($this->status !== self::STATUS_IN_ROW) { Checkers::notice('Bad status, expected: ' . self::STATUS_IN_ROW . ', detected: ' . $this->status); } if ($this->autoCurrentCol + $nbColForThisCell > $this->autoCols) { $src .= $this->endRow()->beginRow(); $this->autoCurrentCol = 0; } $src .= $this->callBeginCell($this->autoCols / $nbColForThisCell, $classes, $attrs); $this->autoCurrentCol += $nbColForThisCell; return $src; }
php
public function autoNewCol(int $nbColForThisCell = 1, array $classes = [], array $attrs = []):string { !$this->autoStarted && $this->autoStart(); $src = ''; $this->status === self::STATUS_IN_CELL && $src .= $this->endCell(); $this->status === self::STATUS_OK && $src .= $this->beginContainer($this->autoFluid, $this->autoContainer, $this->autoContainerClasses); $this->status === self::STATUS_IN_CONTAINER && $src .= $this->beginRow(); if ($this->status !== self::STATUS_IN_ROW) { Checkers::notice('Bad status, expected: ' . self::STATUS_IN_ROW . ', detected: ' . $this->status); } if ($this->autoCurrentCol + $nbColForThisCell > $this->autoCols) { $src .= $this->endRow()->beginRow(); $this->autoCurrentCol = 0; } $src .= $this->callBeginCell($this->autoCols / $nbColForThisCell, $classes, $attrs); $this->autoCurrentCol += $nbColForThisCell; return $src; }
[ "public", "function", "autoNewCol", "(", "int", "$", "nbColForThisCell", "=", "1", ",", "array", "$", "classes", "=", "[", "]", ",", "array", "$", "attrs", "=", "[", "]", ")", ":", "string", "{", "!", "$", "this", "->", "autoStarted", "&&", "$", "this", "->", "autoStart", "(", ")", ";", "$", "src", "=", "''", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_IN_CELL", "&&", "$", "src", ".=", "$", "this", "->", "endCell", "(", ")", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_OK", "&&", "$", "src", ".=", "$", "this", "->", "beginContainer", "(", "$", "this", "->", "autoFluid", ",", "$", "this", "->", "autoContainer", ",", "$", "this", "->", "autoContainerClasses", ")", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_IN_CONTAINER", "&&", "$", "src", ".=", "$", "this", "->", "beginRow", "(", ")", ";", "if", "(", "$", "this", "->", "status", "!==", "self", "::", "STATUS_IN_ROW", ")", "{", "Checkers", "::", "notice", "(", "'Bad status, expected: '", ".", "self", "::", "STATUS_IN_ROW", ".", "', detected: '", ".", "$", "this", "->", "status", ")", ";", "}", "if", "(", "$", "this", "->", "autoCurrentCol", "+", "$", "nbColForThisCell", ">", "$", "this", "->", "autoCols", ")", "{", "$", "src", ".=", "$", "this", "->", "endRow", "(", ")", "->", "beginRow", "(", ")", ";", "$", "this", "->", "autoCurrentCol", "=", "0", ";", "}", "$", "src", ".=", "$", "this", "->", "callBeginCell", "(", "$", "this", "->", "autoCols", "/", "$", "nbColForThisCell", ",", "$", "classes", ",", "$", "attrs", ")", ";", "$", "this", "->", "autoCurrentCol", "+=", "$", "nbColForThisCell", ";", "return", "$", "src", ";", "}" ]
To call before each data cell @param int $nbColForThisCell @return string
[ "To", "call", "before", "each", "data", "cell" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Grid.php#L393-L410
2,580
osflab/view
Helper/Bootstrap/Grid.php
Grid.autoStop
public function autoStop():string { $src = ''; $this->status === self::STATUS_IN_CELL && $src .= $this->endCell(); $this->status === self::STATUS_IN_ROW && $src .= $this->endRow(); $this->status === self::STATUS_IN_CONTAINER && $src .= $this->endContainer($this->autoContainer); $this->autoCols = self::DEFAULT_COLS; $this->autoFluid = self::DEFAULT_FLUID; $this->autoCurrentCol = 0; $this->autoStarted = false; return $src; }
php
public function autoStop():string { $src = ''; $this->status === self::STATUS_IN_CELL && $src .= $this->endCell(); $this->status === self::STATUS_IN_ROW && $src .= $this->endRow(); $this->status === self::STATUS_IN_CONTAINER && $src .= $this->endContainer($this->autoContainer); $this->autoCols = self::DEFAULT_COLS; $this->autoFluid = self::DEFAULT_FLUID; $this->autoCurrentCol = 0; $this->autoStarted = false; return $src; }
[ "public", "function", "autoStop", "(", ")", ":", "string", "{", "$", "src", "=", "''", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_IN_CELL", "&&", "$", "src", ".=", "$", "this", "->", "endCell", "(", ")", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_IN_ROW", "&&", "$", "src", ".=", "$", "this", "->", "endRow", "(", ")", ";", "$", "this", "->", "status", "===", "self", "::", "STATUS_IN_CONTAINER", "&&", "$", "src", ".=", "$", "this", "->", "endContainer", "(", "$", "this", "->", "autoContainer", ")", ";", "$", "this", "->", "autoCols", "=", "self", "::", "DEFAULT_COLS", ";", "$", "this", "->", "autoFluid", "=", "self", "::", "DEFAULT_FLUID", ";", "$", "this", "->", "autoCurrentCol", "=", "0", ";", "$", "this", "->", "autoStarted", "=", "false", ";", "return", "$", "src", ";", "}" ]
To call at the end of your grid @return string
[ "To", "call", "at", "the", "end", "of", "your", "grid" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Grid.php#L416-L427
2,581
osflab/view
Helper/Bootstrap/Grid.php
Grid.auto
public function auto( array $cellsData, int $nbColsByRow = null, bool $container = false, array $classes = [], array $attrs = [], array $containerClasses = [], bool $fluid = true):string { $nbColsByRow = $nbColsByRow ?? count($cellsData); $src = $this->autoStart($nbColsByRow, $container, $fluid, $containerClasses); foreach ($cellsData as $cell) { $src .= $this->autoNewCol(1, $classes, $attrs); $src .= (string) $cell; } $src .= $this->autoStop(); return $src; }
php
public function auto( array $cellsData, int $nbColsByRow = null, bool $container = false, array $classes = [], array $attrs = [], array $containerClasses = [], bool $fluid = true):string { $nbColsByRow = $nbColsByRow ?? count($cellsData); $src = $this->autoStart($nbColsByRow, $container, $fluid, $containerClasses); foreach ($cellsData as $cell) { $src .= $this->autoNewCol(1, $classes, $attrs); $src .= (string) $cell; } $src .= $this->autoStop(); return $src; }
[ "public", "function", "auto", "(", "array", "$", "cellsData", ",", "int", "$", "nbColsByRow", "=", "null", ",", "bool", "$", "container", "=", "false", ",", "array", "$", "classes", "=", "[", "]", ",", "array", "$", "attrs", "=", "[", "]", ",", "array", "$", "containerClasses", "=", "[", "]", ",", "bool", "$", "fluid", "=", "true", ")", ":", "string", "{", "$", "nbColsByRow", "=", "$", "nbColsByRow", "??", "count", "(", "$", "cellsData", ")", ";", "$", "src", "=", "$", "this", "->", "autoStart", "(", "$", "nbColsByRow", ",", "$", "container", ",", "$", "fluid", ",", "$", "containerClasses", ")", ";", "foreach", "(", "$", "cellsData", "as", "$", "cell", ")", "{", "$", "src", ".=", "$", "this", "->", "autoNewCol", "(", "1", ",", "$", "classes", ",", "$", "attrs", ")", ";", "$", "src", ".=", "(", "string", ")", "$", "cell", ";", "}", "$", "src", ".=", "$", "this", "->", "autoStop", "(", ")", ";", "return", "$", "src", ";", "}" ]
Decorate automatically an array of strings with a grid @param array $cellsData @param int $nbColsByRow @return string
[ "Decorate", "automatically", "an", "array", "of", "strings", "with", "a", "grid" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Grid.php#L477-L494
2,582
bearframework/emails-addon
classes/Emails/Email/Signers.php
Signers.addSMIME
public function addSMIME(string $certificate, string $privateKey): void { $signer = new SMIMESigner(); $signer->certificate = $certificate; $signer->privateKey = $privateKey; $this->set($signer); }
php
public function addSMIME(string $certificate, string $privateKey): void { $signer = new SMIMESigner(); $signer->certificate = $certificate; $signer->privateKey = $privateKey; $this->set($signer); }
[ "public", "function", "addSMIME", "(", "string", "$", "certificate", ",", "string", "$", "privateKey", ")", ":", "void", "{", "$", "signer", "=", "new", "SMIMESigner", "(", ")", ";", "$", "signer", "->", "certificate", "=", "$", "certificate", ";", "$", "signer", "->", "privateKey", "=", "$", "privateKey", ";", "$", "this", "->", "set", "(", "$", "signer", ")", ";", "}" ]
Add a SMIME signer. @param string $certificate @param string $privateKey
[ "Add", "a", "SMIME", "signer", "." ]
43a68c47e2b1d231dc69a324249ff5f6827201ca
https://github.com/bearframework/emails-addon/blob/43a68c47e2b1d231dc69a324249ff5f6827201ca/classes/Emails/Email/Signers.php#L34-L40
2,583
bearframework/emails-addon
classes/Emails/Email/Signers.php
Signers.addDKIM
public function addDKIM(string $privateKey, string $domain, string $selector): void { $signer = new DKIMSigner(); $signer->privateKey = $privateKey; $signer->domain = $domain; $signer->selector = $selector; $this->set($signer); }
php
public function addDKIM(string $privateKey, string $domain, string $selector): void { $signer = new DKIMSigner(); $signer->privateKey = $privateKey; $signer->domain = $domain; $signer->selector = $selector; $this->set($signer); }
[ "public", "function", "addDKIM", "(", "string", "$", "privateKey", ",", "string", "$", "domain", ",", "string", "$", "selector", ")", ":", "void", "{", "$", "signer", "=", "new", "DKIMSigner", "(", ")", ";", "$", "signer", "->", "privateKey", "=", "$", "privateKey", ";", "$", "signer", "->", "domain", "=", "$", "domain", ";", "$", "signer", "->", "selector", "=", "$", "selector", ";", "$", "this", "->", "set", "(", "$", "signer", ")", ";", "}" ]
Add a DKIM signer. @param string $privateKey @param string $domain @param string $selector
[ "Add", "a", "DKIM", "signer", "." ]
43a68c47e2b1d231dc69a324249ff5f6827201ca
https://github.com/bearframework/emails-addon/blob/43a68c47e2b1d231dc69a324249ff5f6827201ca/classes/Emails/Email/Signers.php#L49-L56
2,584
axypro/fs-ifs
Factory.php
Factory.getStandard
public static function getStandard() { if (self::$standard === null) { $cn = self::$standardCN; if (!class_exists($cn, true)) { throw new \LogicException('The standard FS implementation not installed'); } if (!is_subclass_of($cn, self::$interface)) { throw new \LogicException('OMG, standard FS is fake'); } self::$standard = new $cn; } return self::$standard; }
php
public static function getStandard() { if (self::$standard === null) { $cn = self::$standardCN; if (!class_exists($cn, true)) { throw new \LogicException('The standard FS implementation not installed'); } if (!is_subclass_of($cn, self::$interface)) { throw new \LogicException('OMG, standard FS is fake'); } self::$standard = new $cn; } return self::$standard; }
[ "public", "static", "function", "getStandard", "(", ")", "{", "if", "(", "self", "::", "$", "standard", "===", "null", ")", "{", "$", "cn", "=", "self", "::", "$", "standardCN", ";", "if", "(", "!", "class_exists", "(", "$", "cn", ",", "true", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'The standard FS implementation not installed'", ")", ";", "}", "if", "(", "!", "is_subclass_of", "(", "$", "cn", ",", "self", "::", "$", "interface", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'OMG, standard FS is fake'", ")", ";", "}", "self", "::", "$", "standard", "=", "new", "$", "cn", ";", "}", "return", "self", "::", "$", "standard", ";", "}" ]
Returns the standard implementation @return IFS @throws \LogicException the standard implementation not installed
[ "Returns", "the", "standard", "implementation" ]
c89dd140d24bb2e4f61cf59e33e3eb0e16970ad4
https://github.com/axypro/fs-ifs/blob/c89dd140d24bb2e4f61cf59e33e3eb0e16970ad4/Factory.php#L47-L60
2,585
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.arg
public function arg(string $arg): ProcessBuilder { if ($arg === '') { return $this; } $this->arguments[] = $arg; return $this; }
php
public function arg(string $arg): ProcessBuilder { if ($arg === '') { return $this; } $this->arguments[] = $arg; return $this; }
[ "public", "function", "arg", "(", "string", "$", "arg", ")", ":", "ProcessBuilder", "{", "if", "(", "$", "arg", "===", "''", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "arguments", "[", "]", "=", "$", "arg", ";", "return", "$", "this", ";", "}" ]
Adds an argument @param string $arg The command argument @return ProcessBuilder
[ "Adds", "an", "argument" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L138-L147
2,586
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.option
public function option(string $option, ?string $value = null): ProcessBuilder { if ($option === '') { return $this; } if (strpos($option, '-') !== 0) { $option = sprintf('--%s', $option); } $this->arguments[] = $option; if ($value !== null) { $this->arguments[] = $value; } return $this; }
php
public function option(string $option, ?string $value = null): ProcessBuilder { if ($option === '') { return $this; } if (strpos($option, '-') !== 0) { $option = sprintf('--%s', $option); } $this->arguments[] = $option; if ($value !== null) { $this->arguments[] = $value; } return $this; }
[ "public", "function", "option", "(", "string", "$", "option", ",", "?", "string", "$", "value", "=", "null", ")", ":", "ProcessBuilder", "{", "if", "(", "$", "option", "===", "''", ")", "{", "return", "$", "this", ";", "}", "if", "(", "strpos", "(", "$", "option", ",", "'-'", ")", "!==", "0", ")", "{", "$", "option", "=", "sprintf", "(", "'--%s'", ",", "$", "option", ")", ";", "}", "$", "this", "->", "arguments", "[", "]", "=", "$", "option", ";", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "this", "->", "arguments", "[", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Adds an option @param string $option The command option @param string|null $value The option value @return ProcessBuilder
[ "Adds", "an", "option" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L157-L174
2,587
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.input
public function input($input): ProcessBuilder { if ($input === null) { $this->input = null; return $this; } if (is_resource($input)) { $this->input = $input; return $this; } if (is_scalar($input)) { $this->input = (string) $input; } return $this; }
php
public function input($input): ProcessBuilder { if ($input === null) { $this->input = null; return $this; } if (is_resource($input)) { $this->input = $input; return $this; } if (is_scalar($input)) { $this->input = (string) $input; } return $this; }
[ "public", "function", "input", "(", "$", "input", ")", ":", "ProcessBuilder", "{", "if", "(", "$", "input", "===", "null", ")", "{", "$", "this", "->", "input", "=", "null", ";", "return", "$", "this", ";", "}", "if", "(", "is_resource", "(", "$", "input", ")", ")", "{", "$", "this", "->", "input", "=", "$", "input", ";", "return", "$", "this", ";", "}", "if", "(", "is_scalar", "(", "$", "input", ")", ")", "{", "$", "this", "->", "input", "=", "(", "string", ")", "$", "input", ";", "}", "return", "$", "this", ";", "}" ]
Sets the input @param resource|string|null $input The input @return ProcessBuilder
[ "Sets", "the", "input" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L236-L255
2,588
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.timeout
public function timeout($timeout): ProcessBuilder { if ($timeout === null) { $this->timeout = null; return $this; } $timeout = (float) $timeout; if ($timeout < 0) { throw new DomainException('Timeout must be a positive number'); } $this->timeout = $timeout; return $this; }
php
public function timeout($timeout): ProcessBuilder { if ($timeout === null) { $this->timeout = null; return $this; } $timeout = (float) $timeout; if ($timeout < 0) { throw new DomainException('Timeout must be a positive number'); } $this->timeout = $timeout; return $this; }
[ "public", "function", "timeout", "(", "$", "timeout", ")", ":", "ProcessBuilder", "{", "if", "(", "$", "timeout", "===", "null", ")", "{", "$", "this", "->", "timeout", "=", "null", ";", "return", "$", "this", ";", "}", "$", "timeout", "=", "(", "float", ")", "$", "timeout", ";", "if", "(", "$", "timeout", "<", "0", ")", "{", "throw", "new", "DomainException", "(", "'Timeout must be a positive number'", ")", ";", "}", "$", "this", "->", "timeout", "=", "$", "timeout", ";", "return", "$", "this", ";", "}" ]
Sets the timeout in seconds @param int|float|null $timeout The timeout in seconds @return ProcessBuilder @throws DomainException When the timeout is invalid
[ "Sets", "the", "timeout", "in", "seconds" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L266-L283
2,589
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.setEnv
public function setEnv(string $name, ?string $value = null): ProcessBuilder { $this->environment[$name] = $value; return $this; }
php
public function setEnv(string $name, ?string $value = null): ProcessBuilder { $this->environment[$name] = $value; return $this; }
[ "public", "function", "setEnv", "(", "string", "$", "name", ",", "?", "string", "$", "value", "=", "null", ")", ":", "ProcessBuilder", "{", "$", "this", "->", "environment", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets an environment variable @param string $name The variable name @param string|null $value The variable value @return ProcessBuilder
[ "Sets", "an", "environment", "variable" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L307-L312
2,590
novuso/common
src/Application/Process/ProcessBuilder.php
ProcessBuilder.getProcess
public function getProcess(): Process { if (count($this->prefix) === 0 && count($this->arguments) === 0) { throw new MethodCallException('You must add arguments before calling getProcess()'); } $arguments = array_merge($this->prefix, $this->arguments); $command = implode(' ', array_map('escapeshellarg', $arguments)); if ($this->inheritEnv) { $env = array_replace($_SERVER, $this->environment); } else { $env = $this->environment; } $process = new Process( $command, $this->directory, $env, $this->input, $this->timeout, $this->stdout, $this->stderr ); if ($this->outputDisabled) { $process->disableOutput(); } return $process; }
php
public function getProcess(): Process { if (count($this->prefix) === 0 && count($this->arguments) === 0) { throw new MethodCallException('You must add arguments before calling getProcess()'); } $arguments = array_merge($this->prefix, $this->arguments); $command = implode(' ', array_map('escapeshellarg', $arguments)); if ($this->inheritEnv) { $env = array_replace($_SERVER, $this->environment); } else { $env = $this->environment; } $process = new Process( $command, $this->directory, $env, $this->input, $this->timeout, $this->stdout, $this->stderr ); if ($this->outputDisabled) { $process->disableOutput(); } return $process; }
[ "public", "function", "getProcess", "(", ")", ":", "Process", "{", "if", "(", "count", "(", "$", "this", "->", "prefix", ")", "===", "0", "&&", "count", "(", "$", "this", "->", "arguments", ")", "===", "0", ")", "{", "throw", "new", "MethodCallException", "(", "'You must add arguments before calling getProcess()'", ")", ";", "}", "$", "arguments", "=", "array_merge", "(", "$", "this", "->", "prefix", ",", "$", "this", "->", "arguments", ")", ";", "$", "command", "=", "implode", "(", "' '", ",", "array_map", "(", "'escapeshellarg'", ",", "$", "arguments", ")", ")", ";", "if", "(", "$", "this", "->", "inheritEnv", ")", "{", "$", "env", "=", "array_replace", "(", "$", "_SERVER", ",", "$", "this", "->", "environment", ")", ";", "}", "else", "{", "$", "env", "=", "$", "this", "->", "environment", ";", "}", "$", "process", "=", "new", "Process", "(", "$", "command", ",", "$", "this", "->", "directory", ",", "$", "env", ",", "$", "this", "->", "input", ",", "$", "this", "->", "timeout", ",", "$", "this", "->", "stdout", ",", "$", "this", "->", "stderr", ")", ";", "if", "(", "$", "this", "->", "outputDisabled", ")", "{", "$", "process", "->", "disableOutput", "(", ")", ";", "}", "return", "$", "process", ";", "}" ]
Creates a Process instance @return Process @throws MethodCallException When arguments are not present
[ "Creates", "a", "Process", "instance" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Process/ProcessBuilder.php#L373-L403
2,591
jfortunato/fortune
src/Repository/DoctrineResourceRepository.php
DoctrineResourceRepository.fillAttributes
protected function fillAttributes($resource, array $attributes) { foreach ($attributes as $attribute => $value) { $setter = "set" . ucfirst($attribute); if (method_exists($resource, $setter)) { $resource->$setter($value); } } }
php
protected function fillAttributes($resource, array $attributes) { foreach ($attributes as $attribute => $value) { $setter = "set" . ucfirst($attribute); if (method_exists($resource, $setter)) { $resource->$setter($value); } } }
[ "protected", "function", "fillAttributes", "(", "$", "resource", ",", "array", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "value", ")", "{", "$", "setter", "=", "\"set\"", ".", "ucfirst", "(", "$", "attribute", ")", ";", "if", "(", "method_exists", "(", "$", "resource", ",", "$", "setter", ")", ")", "{", "$", "resource", "->", "$", "setter", "(", "$", "value", ")", ";", "}", "}", "}" ]
Sets all the properties on the entity. @param mixed $resource @param array $attributes @return void
[ "Sets", "all", "the", "properties", "on", "the", "entity", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Repository/DoctrineResourceRepository.php#L142-L151
2,592
fullpipe/image-bundle
Form/EventListener/BuildImageFormListener.php
BuildImageFormListener.postSubmit
public function postSubmit(FormEvent $event) { $image = $event->getData(); if ($image && $image->hasFile()) { $image->setPath(null); } }
php
public function postSubmit(FormEvent $event) { $image = $event->getData(); if ($image && $image->hasFile()) { $image->setPath(null); } }
[ "public", "function", "postSubmit", "(", "FormEvent", "$", "event", ")", "{", "$", "image", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "$", "image", "&&", "$", "image", "->", "hasFile", "(", ")", ")", "{", "$", "image", "->", "setPath", "(", "null", ")", ";", "}", "}" ]
Post form submit listener @param FormEvent $event
[ "Post", "form", "submit", "listener" ]
717e75a4f549e40140bde262da742978f39a7e84
https://github.com/fullpipe/image-bundle/blob/717e75a4f549e40140bde262da742978f39a7e84/Form/EventListener/BuildImageFormListener.php#L42-L49
2,593
phossa2/libs
src/Phossa2/Di/Resolver/Resolver.php
Resolver.resolve
public function resolve(&$toResolve) { if ($this->config_resolver instanceof ReferenceInterface) { $this->config_resolver->deReferenceArray($toResolve); } return $this; }
php
public function resolve(&$toResolve) { if ($this->config_resolver instanceof ReferenceInterface) { $this->config_resolver->deReferenceArray($toResolve); } return $this; }
[ "public", "function", "resolve", "(", "&", "$", "toResolve", ")", "{", "if", "(", "$", "this", "->", "config_resolver", "instanceof", "ReferenceInterface", ")", "{", "$", "this", "->", "config_resolver", "->", "deReferenceArray", "(", "$", "toResolve", ")", ";", "}", "return", "$", "this", ";", "}" ]
Resolving use the parameter resolver {@inheritDoc}
[ "Resolving", "use", "the", "parameter", "resolver" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Resolver/Resolver.php#L112-L118
2,594
phossa2/libs
src/Phossa2/Di/Resolver/Resolver.php
Resolver.hasService
public function hasService(/*# string */ $id = '')/*# : bool */ { $sid = $this->getSectionId($id); // direct match if ($this->has($sid)) { return true; } // autoclass if ($this->autoClassName($id)) { return true; } // translation if ($this->serviceTranslation($id)) { return true; } return false; }
php
public function hasService(/*# string */ $id = '')/*# : bool */ { $sid = $this->getSectionId($id); // direct match if ($this->has($sid)) { return true; } // autoclass if ($this->autoClassName($id)) { return true; } // translation if ($this->serviceTranslation($id)) { return true; } return false; }
[ "public", "function", "hasService", "(", "/*# string */", "$", "id", "=", "''", ")", "/*# : bool */", "{", "$", "sid", "=", "$", "this", "->", "getSectionId", "(", "$", "id", ")", ";", "// direct match", "if", "(", "$", "this", "->", "has", "(", "$", "sid", ")", ")", "{", "return", "true", ";", "}", "// autoclass", "if", "(", "$", "this", "->", "autoClassName", "(", "$", "id", ")", ")", "{", "return", "true", ";", "}", "// translation", "if", "(", "$", "this", "->", "serviceTranslation", "(", "$", "id", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Autowiring support added {@inheritDoc} @since 2.1.0 added service translation
[ "Autowiring", "support", "added" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Resolver/Resolver.php#L138-L158
2,595
phossa2/libs
src/Phossa2/Di/Resolver/Resolver.php
Resolver.autoClassName
protected function autoClassName(/*# string */ $id)/*# : bool */ { if ($this->auto && class_exists($id) && $this->isWritable()) { return $this->setService($id, $id); } return false; }
php
protected function autoClassName(/*# string */ $id)/*# : bool */ { if ($this->auto && class_exists($id) && $this->isWritable()) { return $this->setService($id, $id); } return false; }
[ "protected", "function", "autoClassName", "(", "/*# string */", "$", "id", ")", "/*# : bool */", "{", "if", "(", "$", "this", "->", "auto", "&&", "class_exists", "(", "$", "id", ")", "&&", "$", "this", "->", "isWritable", "(", ")", ")", "{", "return", "$", "this", "->", "setService", "(", "$", "id", ",", "$", "id", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if 1) autowiring is true 2) $id is a existing classname 3) resolver $this is writable @param string $id @return bool @access protected
[ "Returns", "true", "if" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Resolver/Resolver.php#L227-L233
2,596
phossa2/libs
src/Phossa2/Di/Resolver/Resolver.php
Resolver.getRawConfig
protected function getRawConfig(/*# string */ $id) { $this->config_resolver->enableDeReference(false); $data = $this->config_resolver->get($id); $this->config_resolver->enableDeReference(true); return $data; }
php
protected function getRawConfig(/*# string */ $id) { $this->config_resolver->enableDeReference(false); $data = $this->config_resolver->get($id); $this->config_resolver->enableDeReference(true); return $data; }
[ "protected", "function", "getRawConfig", "(", "/*# string */", "$", "id", ")", "{", "$", "this", "->", "config_resolver", "->", "enableDeReference", "(", "false", ")", ";", "$", "data", "=", "$", "this", "->", "config_resolver", "->", "get", "(", "$", "id", ")", ";", "$", "this", "->", "config_resolver", "->", "enableDeReference", "(", "true", ")", ";", "return", "$", "data", ";", "}" ]
Get not-dereferenced config from config_resolver @param string $id @return array @access protected
[ "Get", "not", "-", "dereferenced", "config", "from", "config_resolver" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Resolver/Resolver.php#L275-L281
2,597
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.set
public function set($name, $value = null) { is_null($name) or \Arr::set($this->data, $name, $value); return $this; }
php
public function set($name, $value = null) { is_null($name) or \Arr::set($this->data, $name, $value); return $this; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "is_null", "(", "$", "name", ")", "or", "\\", "Arr", "::", "set", "(", "$", "this", "->", "data", ",", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
set session variables @param string|array name of the variable to set or array of values, array(name => value) @param mixed value @access public @return Fuel\Core\Session_Driver
[ "set", "session", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L148-L153
2,598
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.get
public function get($name, $default = null) { if (is_null($name)) { return $this->data; } return \Arr::get($this->data, $name, $default); }
php
public function get($name, $default = null) { if (is_null($name)) { return $this->data; } return \Arr::get($this->data, $name, $default); }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "data", ";", "}", "return", "\\", "Arr", "::", "get", "(", "$", "this", "->", "data", ",", "$", "name", ",", "$", "default", ")", ";", "}" ]
get session variables @access public @param string name of the variable to get @param mixed default value to return if the variable does not exist @return mixed
[ "get", "session", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L165-L172
2,599
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session/driver.php
Session_Driver.key
public function key($name = 'session_id') { return isset($this->keys[$name]) ? $this->keys[$name] : false; }
php
public function key($name = 'session_id') { return isset($this->keys[$name]) ? $this->keys[$name] : false; }
[ "public", "function", "key", "(", "$", "name", "=", "'session_id'", ")", "{", "return", "isset", "(", "$", "this", "->", "keys", "[", "$", "name", "]", ")", "?", "$", "this", "->", "keys", "[", "$", "name", "]", ":", "false", ";", "}" ]
get session key variables @access public @param string name of the variable to get, default is 'session_id' @return mixed contents of the requested variable, or false if not found
[ "get", "session", "key", "variables" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session/driver.php#L183-L186