FileIteratorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 10 2
1
<?php
2
3
namespace Pim\Bundle\ExcelConnectorBundle\Iterator;
4
5
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8
/**
9
 * Factory for file iterators
10
 *
11
 * @author    Antoine Guigan <[email protected]>
12
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
13
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
class FileIteratorFactory
16
{
17
    /** @var ContainerInterface */
18
    protected $container;
19
20
    /**
21
     * @param ContainerInterface $container
22
     */
23
    public function __construct(ContainerInterface $container)
24
    {
25
        $this->container = $container;
26
    }
27
28
    /**
29
     * Creates an iterator for the given arguments
30
     *
31
     * @param string $class    The class of the iterator
32
     * @param string $filePath The file which should be read
33
     * @param array  $options  The options of the iterator
34
     *
35
     * @return \Iterator
36
     */
37
    public function create($class, $filePath, array $options = array())
38
    {
39
        $iterator = new $class($filePath, $options);
40
41
        if ($iterator instanceof ContainerAwareInterface) {
42
            $iterator->setContainer($this->container);
43
        }
44
45
        return $iterator;
46
    }
47
}
48