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

PictureModel::getAllInfo()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MalScraper\Model;
4
5
use MalScraper\Helper\Helper;
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;
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
        return call_user_func_array([$this, $method], $arguments);
58
    }
59
60
    /**
61
     * Get type (anime or manga).
62
     *
63
     * @return string
64
     */
65
    private function getType()
66
    {
67
        return $this->_type;
68
    }
69
70
    /**
71
     * Get anime/manga id.
72
     *
73
     * @return string
74
     */
75
    private function getId()
76
    {
77
    	return $this->_id;
78
    }
79
80
    /**
81
     * Get anime/manga additional pictures.
82
     *
83
     * @return array
84
     */
85
    private function getAllInfo()
86
    {
87
        $data = [];
88
        $picture_table = $this->_parser->find('table', 0);
89
        if ($picture_table) {
90
            foreach ($picture_table->find('img') as $each_picture) {
91
                if ($each_picture) {
92
                    $data[] = $each_picture->src;
93
                }
94
            }
95
        }
96
        return $data;
97
    }
98
}