gocobachi /
compressy
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of Compressy. |
||
| 5 | * |
||
| 6 | * (c) Alchemy <[email protected]> |
||
| 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 Gocobachi\Compressy\FileStrategy; |
||
| 13 | |||
| 14 | use Gocobachi\Compressy\Adapter\AdapterContainer; |
||
| 15 | use Gocobachi\Compressy\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) { |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
| 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 | } |
||
| 50 |