@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return array |
324 | 324 | */ |
325 | - private function searchAnime($query, $page=1) |
|
325 | + private function searchAnime($query, $page = 1) |
|
326 | 326 | { |
327 | 327 | return (new searchAnimeManga('anime', $query, $page))->getAllInfo(); |
328 | 328 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return array |
337 | 337 | */ |
338 | - private function searchManga($query, $page=1) |
|
338 | + private function searchManga($query, $page = 1) |
|
339 | 339 | { |
340 | 340 | return (new searchAnimeManga('manga', $query, $page))->getAllInfo(); |
341 | 341 | } |
@@ -13,21 +13,21 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class MainModel |
15 | 15 | { |
16 | - /** |
|
16 | + /** |
|
17 | 17 | * MyAnimeList main URL |
18 | 18 | * |
19 | 19 | * @var string |
20 | 20 | */ |
21 | - protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
21 | + protected $_myAnimeListUrl = 'https://myanimelist.net'; |
|
22 | 22 | |
23 | - /** |
|
23 | + /** |
|
24 | 24 | * Trimmed HtmlDomParser. |
25 | 25 | * |
26 | 26 | * @var \simplehtmldom_1_5\simple_html_dom |
27 | 27 | */ |
28 | - protected $_parser; |
|
28 | + protected $_parser; |
|
29 | 29 | |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * Area to be parsed. |
32 | 32 | * |
33 | 33 | * @var string |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return int |
57 | 57 | */ |
58 | - static function getHeader($url) |
|
59 | - { |
|
60 | - $file_headers = @get_headers($url); |
|
61 | - if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
62 | - return 404; |
|
63 | - } |
|
64 | - return 200; |
|
65 | - } |
|
58 | + static function getHeader($url) |
|
59 | + { |
|
60 | + $file_headers = @get_headers($url); |
|
61 | + if (empty($file_headers) || $file_headers[0] == 'HTTP/1.1 404 Not Found') { |
|
62 | + return 404; |
|
63 | + } |
|
64 | + return 200; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Get trimmed HtmlDomParser class. |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return \simplehtmldom_1_5\simple_html_dom |
74 | 74 | */ |
75 | - static function getParser($url,$contentDiv, $additionalSetting = false) |
|
76 | - { |
|
77 | - $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
78 | - $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
79 | - $html = $html->outertext; |
|
80 | - $html = str_replace('"', '\"', $html); |
|
81 | - $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
82 | - $html = HtmlDomParser::str_get_html($html); |
|
83 | - |
|
84 | - return $html; |
|
85 | - } |
|
75 | + static function getParser($url,$contentDiv, $additionalSetting = false) |
|
76 | + { |
|
77 | + $html = HtmlDomParser::file_get_html($url)->find($contentDiv, 0); |
|
78 | + $html = !$additionalSetting ? $html : $html->next_sibling(); |
|
79 | + $html = $html->outertext; |
|
80 | + $html = str_replace('"', '\"', $html); |
|
81 | + $html = html_entity_decode($html, ENT_QUOTES, 'UTF-8'); |
|
82 | + $html = HtmlDomParser::str_get_html($html); |
|
83 | + |
|
84 | + return $html; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Header error check. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if (!$model->_error) { |
105 | 105 | $header = self::getHeader($model->_url); |
106 | 106 | if ($header == 200) { |
107 | - $additionalSetting = ($className == 'CharacterPeoplePictureModel'); |
|
107 | + $additionalSetting = ($className == 'CharacterPeoplePictureModel'); |
|
108 | 108 | $model->_parser = self::getParser(self::getAbsoluteUrl($model), $model->_parserArea, $additionalSetting); |
109 | 109 | } else { |
110 | 110 | $model->_error = $header; |
@@ -121,31 +121,31 @@ discard block |
||
121 | 121 | */ |
122 | 122 | static function getAbsoluteUrl($model) |
123 | 123 | { |
124 | - $className = self::getCleanClassName($model); |
|
125 | - $additionalUrl = ''; |
|
126 | - |
|
127 | - switch ($className) { |
|
128 | - case 'CharacterStaffModel': |
|
129 | - $area = 'li a[href$=characters]'; |
|
130 | - break; |
|
131 | - case 'StatModel': |
|
132 | - $area = 'li a[href$=stats]'; |
|
133 | - $additionalUrl = '?m=all&show=1'; |
|
134 | - break; |
|
135 | - case 'PictureModel': |
|
136 | - $area = 'li a[href$=pics]'; |
|
137 | - break; |
|
138 | - case 'CharacterPeoplePictureModel': |
|
139 | - $area = 'li a[href$=pictures]'; |
|
140 | - break; |
|
141 | - default: |
|
142 | - return $model->_url; |
|
143 | - } |
|
144 | - |
|
145 | - $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
146 | - |
|
147 | - if ($model->getType() == 'manga') |
|
148 | - return 'https://myanimelist.net'.$html.$additionalUrl; |
|
124 | + $className = self::getCleanClassName($model); |
|
125 | + $additionalUrl = ''; |
|
126 | + |
|
127 | + switch ($className) { |
|
128 | + case 'CharacterStaffModel': |
|
129 | + $area = 'li a[href$=characters]'; |
|
130 | + break; |
|
131 | + case 'StatModel': |
|
132 | + $area = 'li a[href$=stats]'; |
|
133 | + $additionalUrl = '?m=all&show=1'; |
|
134 | + break; |
|
135 | + case 'PictureModel': |
|
136 | + $area = 'li a[href$=pics]'; |
|
137 | + break; |
|
138 | + case 'CharacterPeoplePictureModel': |
|
139 | + $area = 'li a[href$=pictures]'; |
|
140 | + break; |
|
141 | + default: |
|
142 | + return $model->_url; |
|
143 | + } |
|
144 | + |
|
145 | + $html = HtmlDomParser::file_get_html($model->_url)->find($area, 0)->href; |
|
146 | + |
|
147 | + if ($model->getType() == 'manga') |
|
148 | + return 'https://myanimelist.net'.$html.$additionalUrl; |
|
149 | 149 | return $html.$additionalUrl; |
150 | 150 | } |
151 | 151 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @var string |
17 | 17 | */ |
18 | - private $_type; |
|
18 | + private $_type; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Default constructor. |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function __construct($type, $parserArea = '.anime-manga-search') |
|
28 | + public function __construct($type, $parserArea = '.anime-manga-search') |
|
29 | 29 | { |
30 | - $this->_type = $type; |
|
30 | + $this->_type = $type; |
|
31 | 31 | if ($type == 'anime') { |
32 | 32 | $this->_url = $this->_myAnimeListUrl.'/anime/producer'; |
33 | 33 | } else { |
34 | 34 | $this->_url = $this->_myAnimeListUrl.'/manga/magazine'; |
35 | 35 | } |
36 | - $this->_parserArea = $parserArea; |
|
36 | + $this->_parserArea = $parserArea; |
|
37 | 37 | |
38 | 38 | parent::errorCheck($this); |
39 | 39 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @var string |
17 | 17 | */ |
18 | - private $_type; |
|
18 | + private $_type; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Default constructor. |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | - public function __construct($type, $parserArea = '.anime-manga-search .genre-link') |
|
28 | + public function __construct($type, $parserArea = '.anime-manga-search .genre-link') |
|
29 | 29 | { |
30 | - $this->_type = $type; |
|
30 | + $this->_type = $type; |
|
31 | 31 | if ($type == 'anime') { |
32 | 32 | $this->_url = $this->_myAnimeListUrl.'/anime.php'; |
33 | 33 | } else { |
34 | 34 | $this->_url = $this->_myAnimeListUrl.'/manga.php'; |
35 | 35 | } |
36 | - $this->_parserArea = $parserArea; |
|
36 | + $this->_parserArea = $parserArea; |
|
37 | 37 | |
38 | 38 | parent::errorCheck($this); |
39 | 39 | } |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function __call($method, $arguments) |
55 | 55 | { |
56 | - if ($this->_error) |
|
57 | - return $this->_error; |
|
56 | + if ($this->_error) { |
|
57 | + return $this->_error; |
|
58 | + } |
|
58 | 59 | return call_user_func_array([$this, $method], $arguments); |
59 | 60 | } |
60 | 61 | |
@@ -118,8 +119,9 @@ discard block |
||
118 | 119 | } |
119 | 120 | |
120 | 121 | $char_table = $char_table->next_sibling(); |
121 | - if ($char_table->tag == 'br' || $char_table->tag == 'a' || $char_table->tag == 'h2' || $char_table->tag == 'div') |
|
122 | - break; |
|
122 | + if ($char_table->tag == 'br' || $char_table->tag == 'a' || $char_table->tag == 'h2' || $char_table->tag == 'div') { |
|
123 | + break; |
|
124 | + } |
|
123 | 125 | $character_index++; |
124 | 126 | } |
125 | 127 | } |
@@ -250,8 +252,9 @@ discard block |
||
250 | 252 | $staff[$staff_index]['role'] = $this->getCharacterRole($staff_name_area); |
251 | 253 | |
252 | 254 | $staff_table = $staff_table->next_sibling(); |
253 | - if (!$staff_table) |
|
254 | - break; |
|
255 | + if (!$staff_table) { |
|
256 | + break; |
|
257 | + } |
|
255 | 258 | $staff_index++; |
256 | 259 | } |
257 | 260 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @var string|int |
24 | 24 | */ |
25 | - private $_id; |
|
25 | + private $_id; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Default constructor. |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | - public function __construct($type, $id, $parserArea = '#content table tr td') |
|
35 | + public function __construct($type, $id, $parserArea = '#content table tr td') |
|
36 | 36 | { |
37 | - $this->_type = $type; |
|
37 | + $this->_type = $type; |
|
38 | 38 | $this->_id = $id; |
39 | 39 | if ($this->_type == 'people') { |
40 | 40 | $this->_url = $this->_myAnimeListUrl.'/people/'.$id; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | private function getId() |
80 | 80 | { |
81 | - return $this->_id; |
|
81 | + return $this->_id; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @var string|int |
31 | 31 | */ |
32 | - private $_id; |
|
32 | + private $_id; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Page number. |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return void |
50 | 50 | */ |
51 | - public function __construct($type, $type2, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
51 | + public function __construct($type, $type2, $id, $page = 1, $parserArea = '#content .js-categories-seasonal') |
|
52 | 52 | { |
53 | 53 | $this->_type = $type; |
54 | 54 | $this->_type2 = $type2; |
55 | 55 | $this->_id = $id; |
56 | - $this->_page = $page; |
|
56 | + $this->_page = $page; |
|
57 | 57 | |
58 | 58 | if ($type2 == 'producer') { |
59 | 59 | if ($type == 'anime') { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @var string |
17 | 17 | */ |
18 | - private $_type; |
|
18 | + private $_type; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Search query. |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function __construct($type, $query, $page, $parserArea = 'div[class^=js-categories-seasonal]') |
|
44 | + public function __construct($type, $query, $page, $parserArea = 'div[class^=js-categories-seasonal]') |
|
45 | 45 | { |
46 | 46 | $this->_type = $type; |
47 | - $this->_query = $query; |
|
47 | + $this->_query = $query; |
|
48 | 48 | $this->_page = 50 * ($page - 1); |
49 | 49 | |
50 | 50 | if ($type == 'anime') { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } else { |
53 | 53 | $this->_url = $this->_myAnimeListUrl.'/manga.php?q='.$query.'&show='.$this->_page; |
54 | 54 | } |
55 | - $this->_parserArea = $parserArea; |
|
55 | + $this->_parserArea = $parserArea; |
|
56 | 56 | |
57 | 57 | parent::errorCheck($this); |
58 | 58 | } |