Passed
Push — feature/super-model ( 24c950...13c8a0 )
by axel
02:30
created

CharacterPictureModel   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 78
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

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