Completed
Pull Request — master (#132)
by
unknown
06:43 queued 04:56
created

AbstractFileStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAdapters() 0 13 3
getServiceNames() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of Zippy.
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 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) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
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