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

StrategyChain.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 1.72 KiB


01  <?php
02  /**
03   * Zend Framework (http://framework.zend.com/)
04   *
05   * @link      http://github.com/zendframework/zf2 for the canonical source repository
06   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
07   * @license   http://framework.zend.com/license/new-bsd New BSD License
08   */
09   
10  namespace Zend\Stdlib\Hydrator\Strategy;
11   
12  use Traversable;
13  use Zend\Stdlib\ArrayUtils;
14   
15  final class StrategyChain implements StrategyInterface
16  {
17      /**
18       * Strategy chain for extraction
19       *
20       * @var StrategyInterface[]
21       */
22      private $extractionStrategies;
23   
24      /**
25       * Strategy chain for hydration
26       *
27       * @var StrategyInterface[]
28       */
29      private $hydrationStrategies;
30   
31      /**
32       * Constructor
33       *
34       * @param array|Traversable $extractionStrategies
35       */
36      public function __construct($extractionStrategies)
37      {
38          $extractionStrategies = ArrayUtils::iteratorToArray($extractionStrategies);
39          $this->extractionStrategies = array_map(
40              function (StrategyInterface $strategy) {
41                  // this callback is here only to ensure type-safety
42                  return $strategy;
43              },
44              $extractionStrategies
45          );
46   
47          $this->hydrationStrategies = array_reverse($extractionStrategies);
48      }
49   
50      /**
51       * {@inheritDoc}
52       */
53      public function extract($value)
54      {
55          foreach ($this->extractionStrategies as $strategy) {
56              $value = $strategy->extract($value);
57          }
58   
59          return $value;
60      }
61   
62      /**
63       * {@inheritDoc}
64       */
65      public function hydrate($value)
66      {
67          foreach ($this->hydrationStrategies as $strategy) {
68              $value = $strategy->hydrate($value);
69          }
70   
71          return $value;
72      }
73  }
74