@@ -116,6 +116,9 @@ |
||
116 | 116 | return array_change_key_case($args, CASE_LOWER); |
117 | 117 | } |
118 | 118 | |
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
119 | 122 | private function getMethod($name) |
120 | 123 | { |
121 | 124 | foreach(get_class_methods($this) as $method) { |
@@ -44,7 +44,7 @@ |
||
44 | 44 | 3 => 5, |
45 | 45 | 1 => 8, |
46 | 46 | 0 => 10, |
47 | - ]; |
|
47 | + ]; |
|
48 | 48 | /** |
49 | 49 | * @var string $imageCount |
50 | 50 | */ |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | |
119 | 119 | private function getMethod($name) |
120 | 120 | { |
121 | - foreach(get_class_methods($this) as $method) { |
|
122 | - if(stripos($name, $method) !== false) { |
|
121 | + foreach (get_class_methods($this) as $method) { |
|
122 | + if (stripos($name, $method) !== false) { |
|
123 | 123 | return $method; |
124 | 124 | } |
125 | 125 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | private function getArgs($name) |
131 | 131 | { |
132 | - foreach(get_object_vars($this) as $property => $value) { |
|
132 | + foreach (get_object_vars($this) as $property => $value) { |
|
133 | 133 | if (stripos($property, $name) !== false) { |
134 | 134 | return $property; |
135 | 135 | } |
@@ -30,6 +30,9 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public $bump; |
32 | 32 | |
33 | + /** |
|
34 | + * @param string $url |
|
35 | + */ |
|
33 | 36 | function __construct($url) |
34 | 37 | { |
35 | 38 | parent::__construct($url); |
@@ -46,7 +49,7 @@ discard block |
||
46 | 49 | /** |
47 | 50 | * Creates DOMXPath object from content |
48 | 51 | * |
49 | - * @return object |
|
52 | + * @return \DOMXPath |
|
50 | 53 | */ |
51 | 54 | protected function document(\DOMDocument $doc) |
52 | 55 | { |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | public function username() |
100 | 100 | { |
101 | 101 | return $this->find('//meta[@name="author"]') |
102 | - ->item(0) |
|
103 | - ->getAttribute('content'); |
|
102 | + ->item(0) |
|
103 | + ->getAttribute('content'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | public function userID() |
112 | 112 | { |
113 | 113 | $query = $this->find( |
114 | - '//div[contains(@class,"seller-detail-info")]' . |
|
115 | - '/span[contains(@class,"username")]/a' |
|
114 | + '//div[contains(@class,"seller-detail-info")]' . |
|
115 | + '/span[contains(@class,"username")]/a' |
|
116 | 116 | )->item(0) |
117 | 117 | ->getAttribute('href'); |
118 | 118 | $query = explode('/', $query); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | public function feedbackPercent() |
173 | 173 | { |
174 | 174 | $query = $this->find( |
175 | - '//div[contains(@class,"seller-detail-info")]' . |
|
176 | - '/span[contains(@class,"feedback")]' |
|
175 | + '//div[contains(@class,"seller-detail-info")]' . |
|
176 | + '/span[contains(@class,"feedback")]' |
|
177 | 177 | )->item(0) |
178 | 178 | ->getElementsByTagName('strong') |
179 | 179 | ->item(0) |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | public function joinDate() |
191 | 191 | { |
192 | 192 | $query = $this->find( |
193 | - '//div[contains(@class,"seller-detail-info")]' . |
|
194 | - '/span[not(@class)]' |
|
193 | + '//div[contains(@class,"seller-detail-info")]' . |
|
194 | + '/span[not(@class)]' |
|
195 | 195 | )->item(0) |
196 | 196 | ->nodeValue; |
197 | 197 | $query = str_replace('join: ', '', strtolower($query)); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public function threadPublished() |
223 | 223 | { |
224 | 224 | $query = $this->find( |
225 | - '//div[contains(@class,"user-details")]/time' |
|
225 | + '//div[contains(@class,"user-details")]/time' |
|
226 | 226 | )->item(0) |
227 | 227 | ->getAttribute('datetime'); |
228 | 228 | $date = new \DateTime($query); |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | $product['bump'] = trim($content); |
261 | 261 | if (strpos(trim($content), 'ago') !== false) { |
262 | 262 | $bumpTime = explode(' ', trim($content)); |
263 | - $date = new \DateTime; |
|
264 | - $date->modify('- '.$bumpTime[0] . ' '. $bumpTime[1]); |
|
263 | + $date = new \DateTime; |
|
264 | + $date->modify('- '.$bumpTime[0] . ' '. $bumpTime[1]); |
|
265 | 265 | |
266 | - $this->bump = $date->format('Y-m-d H:i:s'); |
|
266 | + $this->bump = $date->format('Y-m-d H:i:s'); |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
@@ -273,6 +273,6 @@ discard block |
||
273 | 273 | 'sold' => $this->sold, |
274 | 274 | 'cod' => $this->cod, |
275 | 275 | 'bump' => $this->bump, |
276 | - ]; |
|
276 | + ]; |
|
277 | 277 | } |
278 | 278 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | date_default_timezone_set('Asia/Jakarta'); |
37 | 37 | libxml_use_internal_errors(true); |
38 | 38 | |
39 | - if ($this->header['http_code'] != 200 ) { |
|
39 | + if ($this->header['http_code'] != 200) { |
|
40 | 40 | throw new \Exception("URL not found!"); |
41 | 41 | } |
42 | 42 | |
@@ -245,23 +245,23 @@ discard block |
||
245 | 245 | $titleEntity = trim(explode(':', $nodeValue)[0]); |
246 | 246 | $content = explode(':', $nodeValue)[1]; |
247 | 247 | |
248 | - if($titleEntity === 'terjual') { |
|
248 | + if ($titleEntity === 'terjual') { |
|
249 | 249 | $content = trim($content); |
250 | 250 | $this->sold = explode(' ', $content)[0] + 0; |
251 | 251 | } |
252 | 252 | |
253 | - if($titleEntity === 'lokasi') { |
|
254 | - if(strpos($content, 'bisa cod') !== false) { |
|
253 | + if ($titleEntity === 'lokasi') { |
|
254 | + if (strpos($content, 'bisa cod') !== false) { |
|
255 | 255 | $this->cod = true; |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if($titleEntity === 'last sundul') { |
|
259 | + if ($titleEntity === 'last sundul') { |
|
260 | 260 | $product['bump'] = trim($content); |
261 | 261 | if (strpos(trim($content), 'ago') !== false) { |
262 | 262 | $bumpTime = explode(' ', trim($content)); |
263 | 263 | $date = new \DateTime; |
264 | - $date->modify('- '.$bumpTime[0] . ' '. $bumpTime[1]); |
|
264 | + $date->modify('- ' . $bumpTime[0] . ' ' . $bumpTime[1]); |
|
265 | 265 | |
266 | 266 | $this->bump = $date->format('Y-m-d H:i:s'); |
267 | 267 | } |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | { |
69 | 69 | |
70 | 70 | $ch = $this->init; |
71 | - curl_setopt_array($ch, ($this->options() + $this->options)); |
|
72 | - if (!$this->content = curl_exec($ch)){ |
|
73 | - throw new \Exception( |
|
74 | - 'CURL ERROR! Code: ' . curl_errno($ch) . |
|
75 | - ' Message: ' . curl_error($ch) |
|
76 | - ); |
|
77 | - } |
|
78 | - $this->header = curl_getinfo($ch); |
|
79 | - curl_close($ch); |
|
71 | + curl_setopt_array($ch, ($this->options() + $this->options)); |
|
72 | + if (!$this->content = curl_exec($ch)){ |
|
73 | + throw new \Exception( |
|
74 | + 'CURL ERROR! Code: ' . curl_errno($ch) . |
|
75 | + ' Message: ' . curl_error($ch) |
|
76 | + ); |
|
77 | + } |
|
78 | + $this->header = curl_getinfo($ch); |
|
79 | + curl_close($ch); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'headers', $this->connection['headers'], |
91 | 91 | 'header', $this->connection['header'], |
92 | 92 | 'content', $this->connection['content'], |
93 | - ]; |
|
93 | + ]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | return [ |
104 | 104 | CURLOPT_RETURNTRANSFER => true, |
105 | 105 | CURLOPT_FOLLOWLOCATION => true, |
106 | - CURLOPT_ENCODING => '', |
|
107 | - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
108 | - ]; |
|
106 | + CURLOPT_ENCODING => '', |
|
107 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
108 | + ]; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | //Grab url id in case $url is not valid as required url |
119 | 119 | $id = $url; |
120 | 120 | if (strpos($url, 'product') !== false) { |
121 | - $id = explode('product',$url); |
|
122 | - $id = end($id); |
|
123 | - $id = explode('/', $id)[1]; |
|
121 | + $id = explode('product',$url); |
|
122 | + $id = end($id); |
|
123 | + $id = explode('/', $id)[1]; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //Set the $id as required url |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $ch = $this->init; |
71 | 71 | curl_setopt_array($ch, ($this->options() + $this->options)); |
72 | - if (!$this->content = curl_exec($ch)){ |
|
72 | + if (!$this->content = curl_exec($ch)) { |
|
73 | 73 | throw new \Exception( |
74 | 74 | 'CURL ERROR! Code: ' . curl_errno($ch) . |
75 | 75 | ' Message: ' . curl_error($ch) |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | //Grab url id in case $url is not valid as required url |
119 | 119 | $id = $url; |
120 | 120 | if (strpos($url, 'product') !== false) { |
121 | - $id = explode('product',$url); |
|
121 | + $id = explode('product', $url); |
|
122 | 122 | $id = end($id); |
123 | 123 | $id = explode('/', $id)[1]; |
124 | 124 | } |