Sheet   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 25.71 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 18
loc 70
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A readActiveSheet() 0 9 1
A readSheetByName() 9 9 1
A readSheetByIndex() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 3
    public function __construct(IExcel $excel)
22
    {
23 3
        $this->parser = $excel;
24 3
    }
25
26
    /**
27
     * Метод чтения документа (c активного листа).
28
     *
29
     * @return array    (Содержимое документа)
30
     *
31
     * @throws PHPExcel_Reader_Exception
32
     */
33 1
    public function readActiveSheet()
34
    {
35 1
        $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 1
                                    ->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 1
                                    ->getActiveSheet()
38 1
                                    ->toArray();
39
40 1
        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 1 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 1
        $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 1
                                    ->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 1
                                    ->getSheetByName($sheetName)
57 1
                                    ->toArray();
58
59 1
        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 1 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 1
        $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 1
                                    ->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 1
                                    ->getSheet($sheetIndex)
77 1
                                    ->toArray();
78
79 1
        return $this->parser->getData($objPHPExcel);
80
    }
81
}