PictureModel::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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