f6f65df007fb7cabdd36c1d54fbc20e4051d2104
[yaffs-website] / vendor / alchemy / zippy / src / FileStrategy / AbstractFileStrategy.php
1 <?php
2
3 /*
4  * This file is part of Zippy.
5  *
6  * (c) Alchemy <info@alchemy.fr>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Alchemy\Zippy\FileStrategy;
13
14 use Alchemy\Zippy\Adapter\AdapterContainer;
15 use Alchemy\Zippy\Exception\RuntimeException;
16
17 abstract class AbstractFileStrategy implements FileStrategyInterface
18 {
19     protected $container;
20
21     public function __construct(AdapterContainer $container)
22     {
23         $this->container = $container;
24     }
25
26     /**
27      * {@inheritdoc}
28      */
29     public function getAdapters()
30     {
31         $services = array();
32         foreach ($this->getServiceNames() as $serviceName) {
33             try {
34                 $services[] = $this->container[$serviceName];
35             } catch (RuntimeException $e) {
36
37             }
38         }
39
40         return $services;
41     }
42
43     /**
44      * Returns an array of service names that defines adapters.
45      *
46      * @return string[]
47      */
48     abstract protected function getServiceNames();
49 }