Passed
Branch feature/super-model (24c950)
by axel
02:55
created

PeoplePictureModel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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