Completed
Push — master ( 6807cf...be3985 )
by Andrey
06:23 queued 03:40
created

Sheet::readActiveSheet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace EFParser;
4
5
use EFParserInterface\ISheetParser,
6
    EFParserInterface\IExcel;
7
8
/**
9
 * Class Sheet
10
 * Класс для парсинга листов
11
 */
12
class Sheet implements ISheetParser
13
{
14
    private $parser;
15
16
    /**
17
     * Конструктор
18
     *
19
     * @param IExcel $excel (Класс реализующий IExcel интерфейс)
20
     */
21
    public function __construct(IExcel $excel)
22
    {
23
        $this->parser = $excel;
24
    }
25
26
    /**
27
     * Метод чтения документа (c активного листа).
28
     *
29
     * @return array    (Содержимое документа)
30
     *
31
     * @throws PHPExcel_Reader_Exception
32
     */
33
    public function readActiveSheet()
34
    {
35
        $objPHPExcel = $this->parser->sourceReader
0 ignored issues
show
Bug introduced by
Accessing sourceReader on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
36
                                    ->load($this->parser->sourceFilePath.$this->parser->sourceFile)
0 ignored issues
show
Bug introduced by
Accessing sourceFilePath on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Bug introduced by
Accessing sourceFile on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
37
                                    ->getActiveSheet()
38
                                    ->toArray();
39
40
        return $this->parser->getData($objPHPExcel);
41
    }
42
43
    /**
44
     * Метод для чтения отдельного листа (по названию).
45
     *
46
     * @param string $sheetName      (Название листа)
47
     *
48
     * @return array                 (Содержимое документа)
49
     *
50
     * @throws PHPExcel_Reader_Exception
51
     */
52 View Code Duplication
    public function readSheetByName($sheetName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $objPHPExcel = $this->parser->sourceReader
0 ignored issues
show
Bug introduced by
Accessing sourceReader on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
55
                                    ->load($this->parser->sourceFilePath.$this->parser->sourceFile)
0 ignored issues
show
Bug introduced by
Accessing sourceFilePath on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Bug introduced by
Accessing sourceFile on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
56
                                    ->getSheetByName($sheetName)
57
                                    ->toArray();
58
59
        return $this->parser->getData($objPHPExcel);
60
    }
61
62
    /**
63
     * Метод для чтения отдельного листа (по индексу).
64
     *
65
     * @param int $sheetIndex   (Индекс листа (счит.с 0))
66
     *
67
     * @return array            (Содержимое документа)
68
     *
69
     * @throws PHPExcel_Exception
70
     * @throws PHPExcel_Reader_Exception
71
     */
72 View Code Duplication
    public function readSheetByIndex($sheetIndex)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        $objPHPExcel = $this->parser->sourceReader
0 ignored issues
show
Bug introduced by
Accessing sourceReader on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
75
                                    ->load($this->parser->sourceFilePath.$this->parser->sourceFile)
0 ignored issues
show
Bug introduced by
Accessing sourceFilePath on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
Bug introduced by
Accessing sourceFile on the interface EFParserInterface\IExcel suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
76
                                    ->getSheet($sheetIndex)
77
                                    ->toArray();
78
79
        return $this->parser->getData($objPHPExcel);
80
    }
81
}