Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 399
Zeile 19... Zeile 19...
19
class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \IteratorAggregate
19
class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \IteratorAggregate
20
{
20
{
21
	/**
21
	/**
22
	 * Transforms array to ArrayHash.
22
	 * Transforms array to ArrayHash.
23
	 * @param  array<T>  $array
23
	 * @param  array<T>  $array
24
	 * @return static
-
 
25
	 */
24
	 */
26
	public static function from(array $array, bool $recursive = true)
25
	public static function from(array $array, bool $recursive = true): static
27
	{
26
	{
28
		$obj = new static;
27
		$obj = new static;
29
		foreach ($array as $key => $value) {
28
		foreach ($array as $key => $value) {
30
			$obj->$key = $recursive && is_array($value)
29
			$obj->$key = $recursive && is_array($value)
31
				? static::from($value, true)
30
				? static::from($value, true)
Zeile 36... Zeile 35...
36
	}
35
	}
Zeile 37... Zeile 36...
37
 
36
 
38
 
37
 
39
	/**
38
	/**
40
	 * Returns an iterator over all items.
39
	 * Returns an iterator over all items.
41
	 * @return \RecursiveArrayIterator<array-key, T>
40
	 * @return \Iterator<int|string, T>
42
	 */
41
	 */
43
	public function getIterator(): \RecursiveArrayIterator
42
	public function &getIterator(): \Iterator
-
 
43
	{
-
 
44
		foreach ((array) $this as $key => $foo) {
44
	{
45
			yield $key => $this->$key;
Zeile 45... Zeile 46...
45
		return new \RecursiveArrayIterator((array) $this);
46
		}
46
	}
47
	}