Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

HasDataTrait.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 1.61 KiB


01  <?php
02  namespace GuzzleHttp;
03   
04  /**
05   * Trait implementing ToArrayInterface, \ArrayAccess, \Countable,
06   * \IteratorAggregate, and some path style methods.
07   */
08  trait HasDataTrait
09  {
10      /** @var array */
11      protected $data = [];
12   
13      public function getIterator()
14      {
15          return new \ArrayIterator($this->data);
16      }
17   
18      public function offsetGet($offset)
19      {
20          return isset($this->data[$offset]) ? $this->data[$offset] : null;
21      }
22   
23      public function offsetSet($offset, $value)
24      {
25          $this->data[$offset] = $value;
26      }
27   
28      public function offsetExists($offset)
29      {
30          return isset($this->data[$offset]);
31      }
32   
33      public function offsetUnset($offset)
34      {
35          unset($this->data[$offset]);
36      }
37   
38      public function toArray()
39      {
40          return $this->data;
41      }
42   
43      public function count()
44      {
45          return count($this->data);
46      }
47   
48      /**
49       * Get a value from the collection using a path syntax to retrieve nested
50       * data.
51       *
52       * @param string $path Path to traverse and retrieve a value from
53       *
54       * @return mixed|null
55       */
56      public function getPath($path)
57      {
58          return Utils::getPath($this->data, $path);
59      }
60   
61      /**
62       * Set a value into a nested array key. Keys will be created as needed to
63       * set the value.
64       *
65       * @param string $path  Path to set
66       * @param mixed  $value Value to set at the key
67       *
68       * @throws \RuntimeException when trying to setPath using a nested path
69       *     that travels through a scalar value
70       */
71      public function setPath($path, $value)
72      {
73          Utils::setPath($this->data, $path, $value);
74      }
75  }
76