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

PictureModel::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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