CharacterPeoplePictureModel   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 22
c 1
b 1
f 0
dl 0
loc 92
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A __construct() 0 12 2
A getType() 0 2 1
A getAllInfo() 0 13 4
A __call() 0 7 2
1
<?php
2
3
namespace MalScraper\Model\Additional;
4
5
use MalScraper\Model\MainModel;
6
7
/**
8
 * CharacterPeoplePictureModel class.
9
 */
10
class CharacterPeoplePictureModel extends MainModel
11
{
12
    /**
13
     * Type of the picture (either character or people).
14
     *
15
     * @var string
16
     */
17
    private $_type;
18
19
    /**
20
     * Id of the people.
21
     *
22
     * @var string|int
23
     */
24
    private $_id;
25
26
    /**
27
     * Default constructor.
28
     *
29
     * @param string|int $id
30
     * @param string     $parserArea
31
     *
32
     * @return void
33
     */
34
    public function __construct($type, $id, $parserArea = '#content table tr td')
35
    {
36
        $this->_type = $type;
37
        $this->_id = $id;
38
        if ($this->_type == 'people') {
39
            $this->_url = $this->_myAnimeListUrl.'/people/'.$id.'/a/pictures';
40
        } else {
41
            $this->_url = $this->_myAnimeListUrl.'/character/'.$id.'/a/pictures';
42
        }
43
        $this->_parserArea = $parserArea;
44
45
        parent::errorCheck($this);
46
    }
47
48
    /**
49
     * Default call.
50
     *
51
     * @param string $method
52
     * @param array  $arguments
53
     *
54
     * @return array|string|int
55
     */
56
    public function __call($method, $arguments)
57
    {
58
        if ($this->_error) {
59
            return $this->_error;
60
        }
61
62
        return call_user_func_array([$this, $method], $arguments);
63
    }
64
65
    /**
66
     * Get type.
67
     *
68
     * @return string
69
     */
70
    private function getType()
71
    {
72
    }
73
74
    /**
75
     * Get people id.
76
     *
77
     * @return string
78
     */
79
    private function getId()
80
    {
81
        return $this->_id;
82
    }
83
84
    /**
85
     * Get people additional pictures.
86
     *
87
     * @return array
88
     */
89
    private function getAllInfo()
90
    {
91
        $data = [];
92
        $picture_table = $this->_parser->find('table', 0);
93
        if ($picture_table) {
94
            foreach ($picture_table->find('img') as $each_picture) {
95
                if ($each_picture) {
96
                    $data[] = $each_picture->src;
97
                }
98
            }
99
        }
100
101
        return $data;
102
    }
103
}
104