Passed
Pull Request — master (#5)
by
unknown
02:50
created
src/Vendors/AbstractVendor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@
 block discarded – undo
145 145
         foreach ($categories as $category) {
146 146
             $item = ['title' => (string) $category->attributes()->text, 'children' => []];
147 147
 
148
-            if (! empty($category->xpath('itunes:category'))) {
148
+            if (!empty($category->xpath('itunes:category'))) {
149 149
                 $inner = $this->fetchCategories($category);
150 150
 
151 151
                 $item['children'] = $inner;
Please login to merge, or discard this patch.
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -7,167 +7,167 @@
 block discarded – undo
7 7
 
8 8
 abstract class AbstractVendor
9 9
 {
10
-    /**
11
-    * @var bool
12
-    */
13
-    protected $isOrginal = false;
14
-
15
-    /**
16
-     * @param SimpleXMLElement $feed
17
-     *
18
-     * @return array
19
-     */
20
-    public function buildFeed(SimpleXMLElement $feed)
21
-    {
22
-        $output = [
23
-            'title'          => (string) $feed->channel->title,
24
-            'description'    => (string) $feed->channel->description,
25
-            'summary'        => (string) $this->getValueByPath($feed->channel, "summary"),
26
-            'image'          => (string) $feed->channel->image->url,
27
-            'site'           => (string) $feed->channel->link,
28
-            'author'         => (string) $this->getValueByPath($feed->channel, "author"),
29
-            'language'       => (string) $feed->channel->language,
30
-            'categories'     => $this->fetchCategories($feed->channel),
31
-            'episode_count'  => (int) count($feed->channel->item),
32
-            'episodes'       => $this->getEpisodes($feed->channel)
33
-        ];
34
-
35
-        return $output;
36
-    }
37
-
38
-    /**
39
-     * @param SimpleXMLElement|mixed $channel
40
-     *
41
-     * @return array
42
-     */
43
-    protected function getEpisodes($channel)
44
-    {
45
-        $items = [];
46
-        foreach ($channel->item as $value) {
47
-            $items[] = [
48
-                'title'        => (string) $value->title,
49
-                'mp3'          => $this->getAudioUrl($value),
50
-                'size'         => $this->getEpisodeSize($value),
51
-                'duration'     => $this->getEpisodeDuration($value),
52
-                'description'  => (string) $value->description,
53
-                'keywords'     => $this->getKeywords($value),
54
-                'link'         => (string) $value->link,
55
-                'image'        => $this->getEpisodeImage($value, $channel),
56
-                'published_at' => $this->getPublishedDate($value),
57
-            ];
58
-        }
59
-
60
-        return $items;
61
-    }
62
-
63
-    /**
64
-    * @return array
65
-    */
66
-    protected function getKeywords($item)
67
-    {
68
-        return array_map('trim', explode(",", $this->getValueByPath($item, 'keywords')));
69
-    }
70
-
71
-    /**
72
-     * @param SimpleXMLElement $value
73
-     *
74
-     * @return null|string
75
-     */
76
-    protected function getAudioUrl($value)
77
-    {
78
-        return isset($value->enclosure) ? (string) $value->enclosure->attributes()->url : null;
79
-    }
80
-
81
-    /**
82
-     * @param SimpleXMLElement $value
83
-     *
84
-     * @return int
85
-     */
86
-    protected function getEpisodeSize($value)
87
-    {
88
-        return isset($value->enclosure) ? (int) $value->enclosure->attributes()->length : 0;
89
-    }
90
-
91
-    /**
92
-     * @param SimpleXMLElement $item
93
-     *
94
-     * @return string
95
-     */
96
-    protected function getPublishedDate($item)
97
-    {
98
-        $published_at = new DateTime();
99
-        $published_at->setTimestamp(strtotime($item->pubDate));
100
-
101
-        return $published_at->format('Y-m-d H:i:s');
102
-    }
103
-
104
-    /**
105
-     * @param SimpleXMLElement|mixed $item
106
-     * @param string $path
107
-     *
108
-     * @return SimpleXMLElement
109
-     */
110
-    protected function getValueByPath($item, $path)
111
-    {
112
-        return empty($item->xpath("itunes:{$path}")) ? null :
113
-            $item->xpath("itunes:{$path}")[0];
114
-    }
115
-
116
-    /**
117
-     * @param SimpleXMLElement|mixed $item
118
-     *
119
-     * @return int
120
-     */
121
-    protected function getEpisodeDuration($item)
122
-    {
123
-        $duration = (string) $this->getValueByPath($item, "duration");
124
-
125
-        $durationArray = explode(":", $duration);
126
-        if (count($durationArray) > 1) {
127
-            sscanf($duration, "%d:%d:%d", $hours, $minutes, $seconds);
128
-
129
-            $duration = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
130
-        }
131
-
132
-        return (int) $duration;
133
-    }
134
-
135
-    /**
136
-     * @param SimpleXMLElement $item
137
-     *
138
-     * @param SimpleXMLElement $channel
139
-     *
140
-     * @return string
141
-     */
142
-    protected function getEpisodeImage($item, $channel)
143
-    {
144
-        $xmlImage = $this->getValueByPath($item, "image");
145
-
146
-        return $xmlImage ? (string) $xmlImage->attributes()->href : (string) $channel->image->url;
147
-    }
148
-
149
-    /**
150
-     * @param SimpleXMLElement|mixed $channel
151
-     *
152
-     * @return array
153
-     */
154
-    protected function fetchCategories($channel)
155
-    {
156
-        $categories = $channel->xpath('itunes:category');
157
-
158
-        $items = [];
159
-        foreach ($categories as $category) {
160
-            $item = ['title' => (string) $category->attributes()->text, 'children' => []];
161
-
162
-            if (! empty($category->xpath('itunes:category'))) {
163
-                $inner = $this->fetchCategories($category);
164
-
165
-                $item['children'] = $inner;
166
-            }
167
-
168
-            $items[] = $item;
169
-        }
170
-
171
-        return $items;
172
-    }
10
+	/**
11
+	 * @var bool
12
+	 */
13
+	protected $isOrginal = false;
14
+
15
+	/**
16
+	 * @param SimpleXMLElement $feed
17
+	 *
18
+	 * @return array
19
+	 */
20
+	public function buildFeed(SimpleXMLElement $feed)
21
+	{
22
+		$output = [
23
+			'title'          => (string) $feed->channel->title,
24
+			'description'    => (string) $feed->channel->description,
25
+			'summary'        => (string) $this->getValueByPath($feed->channel, "summary"),
26
+			'image'          => (string) $feed->channel->image->url,
27
+			'site'           => (string) $feed->channel->link,
28
+			'author'         => (string) $this->getValueByPath($feed->channel, "author"),
29
+			'language'       => (string) $feed->channel->language,
30
+			'categories'     => $this->fetchCategories($feed->channel),
31
+			'episode_count'  => (int) count($feed->channel->item),
32
+			'episodes'       => $this->getEpisodes($feed->channel)
33
+		];
34
+
35
+		return $output;
36
+	}
37
+
38
+	/**
39
+	 * @param SimpleXMLElement|mixed $channel
40
+	 *
41
+	 * @return array
42
+	 */
43
+	protected function getEpisodes($channel)
44
+	{
45
+		$items = [];
46
+		foreach ($channel->item as $value) {
47
+			$items[] = [
48
+				'title'        => (string) $value->title,
49
+				'mp3'          => $this->getAudioUrl($value),
50
+				'size'         => $this->getEpisodeSize($value),
51
+				'duration'     => $this->getEpisodeDuration($value),
52
+				'description'  => (string) $value->description,
53
+				'keywords'     => $this->getKeywords($value),
54
+				'link'         => (string) $value->link,
55
+				'image'        => $this->getEpisodeImage($value, $channel),
56
+				'published_at' => $this->getPublishedDate($value),
57
+			];
58
+		}
59
+
60
+		return $items;
61
+	}
62
+
63
+	/**
64
+	 * @return array
65
+	 */
66
+	protected function getKeywords($item)
67
+	{
68
+		return array_map('trim', explode(",", $this->getValueByPath($item, 'keywords')));
69
+	}
70
+
71
+	/**
72
+	 * @param SimpleXMLElement $value
73
+	 *
74
+	 * @return null|string
75
+	 */
76
+	protected function getAudioUrl($value)
77
+	{
78
+		return isset($value->enclosure) ? (string) $value->enclosure->attributes()->url : null;
79
+	}
80
+
81
+	/**
82
+	 * @param SimpleXMLElement $value
83
+	 *
84
+	 * @return int
85
+	 */
86
+	protected function getEpisodeSize($value)
87
+	{
88
+		return isset($value->enclosure) ? (int) $value->enclosure->attributes()->length : 0;
89
+	}
90
+
91
+	/**
92
+	 * @param SimpleXMLElement $item
93
+	 *
94
+	 * @return string
95
+	 */
96
+	protected function getPublishedDate($item)
97
+	{
98
+		$published_at = new DateTime();
99
+		$published_at->setTimestamp(strtotime($item->pubDate));
100
+
101
+		return $published_at->format('Y-m-d H:i:s');
102
+	}
103
+
104
+	/**
105
+	 * @param SimpleXMLElement|mixed $item
106
+	 * @param string $path
107
+	 *
108
+	 * @return SimpleXMLElement
109
+	 */
110
+	protected function getValueByPath($item, $path)
111
+	{
112
+		return empty($item->xpath("itunes:{$path}")) ? null :
113
+			$item->xpath("itunes:{$path}")[0];
114
+	}
115
+
116
+	/**
117
+	 * @param SimpleXMLElement|mixed $item
118
+	 *
119
+	 * @return int
120
+	 */
121
+	protected function getEpisodeDuration($item)
122
+	{
123
+		$duration = (string) $this->getValueByPath($item, "duration");
124
+
125
+		$durationArray = explode(":", $duration);
126
+		if (count($durationArray) > 1) {
127
+			sscanf($duration, "%d:%d:%d", $hours, $minutes, $seconds);
128
+
129
+			$duration = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
130
+		}
131
+
132
+		return (int) $duration;
133
+	}
134
+
135
+	/**
136
+	 * @param SimpleXMLElement $item
137
+	 *
138
+	 * @param SimpleXMLElement $channel
139
+	 *
140
+	 * @return string
141
+	 */
142
+	protected function getEpisodeImage($item, $channel)
143
+	{
144
+		$xmlImage = $this->getValueByPath($item, "image");
145
+
146
+		return $xmlImage ? (string) $xmlImage->attributes()->href : (string) $channel->image->url;
147
+	}
148
+
149
+	/**
150
+	 * @param SimpleXMLElement|mixed $channel
151
+	 *
152
+	 * @return array
153
+	 */
154
+	protected function fetchCategories($channel)
155
+	{
156
+		$categories = $channel->xpath('itunes:category');
157
+
158
+		$items = [];
159
+		foreach ($categories as $category) {
160
+			$item = ['title' => (string) $category->attributes()->text, 'children' => []];
161
+
162
+			if (! empty($category->xpath('itunes:category'))) {
163
+				$inner = $this->fetchCategories($category);
164
+
165
+				$item['children'] = $inner;
166
+			}
167
+
168
+			$items[] = $item;
169
+		}
170
+
171
+		return $items;
172
+	}
173 173
 }
Please login to merge, or discard this patch.
src/Helpers/Xml.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class Xml
8 8
 {
9
-    /**
10
-     * @param string $xml
11
-     *
12
-     * @return string
13
-     * @throws Exception
14
-     */
15
-    public static function repair($xml)
16
-    {
17
-        if (class_exists("Tidy") === false) {
18
-            throw new Exception("Tidy Class not found", 500);
19
-        }
9
+	/**
10
+	 * @param string $xml
11
+	 *
12
+	 * @return string
13
+	 * @throws Exception
14
+	 */
15
+	public static function repair($xml)
16
+	{
17
+		if (class_exists("Tidy") === false) {
18
+			throw new Exception("Tidy Class not found", 500);
19
+		}
20 20
 
21
-        $config = [
22
-            'indent'     => true,
23
-            'input-xml'  => true,
24
-            'output-xml' => true,
25
-            'wrap'       => false
26
-        ];
21
+		$config = [
22
+			'indent'     => true,
23
+			'input-xml'  => true,
24
+			'output-xml' => true,
25
+			'wrap'       => false
26
+		];
27 27
 
28
-        $xml_repaired = new Tidy();
29
-        $xml_repaired->parseString($xml, $config, 'utf8');
30
-        $xml_repaired->cleanRepair();
28
+		$xml_repaired = new Tidy();
29
+		$xml_repaired->parseString($xml, $config, 'utf8');
30
+		$xml_repaired->cleanRepair();
31 31
 
32
-        return $xml_repaired;
33
-    }
32
+		return $xml_repaired;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
src/Helpers/Request.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -3,58 +3,58 @@
 block discarded – undo
3 3
 
4 4
 class Request
5 5
 {
6
-    /**
7
-     * @var string
8
-     */
9
-    private $contentType;
10
-
11
-    /**
12
-     * @var int
13
-     */
14
-    private $statusCode;
15
-
16
-    /**
17
-     * @param string $url
18
-     * @param array $options
19
-     *
20
-     * @return string
21
-     */
22
-    public function create($url, array $options = [])
23
-    {
24
-        $request = curl_init($url);
25
-
26
-        $default_options = [
27
-           CURLOPT_FAILONERROR    => true,
28
-           CURLOPT_FOLLOWLOCATION => true,
29
-           CURLOPT_RETURNTRANSFER => true,
30
-           CURLOPT_TIMEOUT        => 15,
31
-           CURLOPT_SSL_VERIFYPEER => 0,
32
-           CURLINFO_HEADER_OUT    => true
33
-       ] + $options;
34
-
35
-        curl_setopt_array($request, $default_options);
36
-
37
-        $result = curl_exec($request);
38
-        $this->statusCode = curl_getinfo($request, CURLINFO_HTTP_CODE);
39
-        $this->contentType = curl_getinfo($request, CURLINFO_CONTENT_TYPE);
40
-        curl_close($request);
41
-
42
-        return $result;
43
-    }
44
-
45
-    /**
46
-     * @return int
47
-     */
48
-    public function getStatusCode()
49
-    {
50
-        return $this->statusCode;
51
-    }
52
-
53
-    /**
54
-     * @return string
55
-     */
56
-    public function getContentType()
57
-    {
58
-        return $this->contentType;
59
-    }
6
+	/**
7
+	 * @var string
8
+	 */
9
+	private $contentType;
10
+
11
+	/**
12
+	 * @var int
13
+	 */
14
+	private $statusCode;
15
+
16
+	/**
17
+	 * @param string $url
18
+	 * @param array $options
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function create($url, array $options = [])
23
+	{
24
+		$request = curl_init($url);
25
+
26
+		$default_options = [
27
+		   CURLOPT_FAILONERROR    => true,
28
+		   CURLOPT_FOLLOWLOCATION => true,
29
+		   CURLOPT_RETURNTRANSFER => true,
30
+		   CURLOPT_TIMEOUT        => 15,
31
+		   CURLOPT_SSL_VERIFYPEER => 0,
32
+		   CURLINFO_HEADER_OUT    => true
33
+	   ] + $options;
34
+
35
+		curl_setopt_array($request, $default_options);
36
+
37
+		$result = curl_exec($request);
38
+		$this->statusCode = curl_getinfo($request, CURLINFO_HTTP_CODE);
39
+		$this->contentType = curl_getinfo($request, CURLINFO_CONTENT_TYPE);
40
+		curl_close($request);
41
+
42
+		return $result;
43
+	}
44
+
45
+	/**
46
+	 * @return int
47
+	 */
48
+	public function getStatusCode()
49
+	{
50
+		return $this->statusCode;
51
+	}
52
+
53
+	/**
54
+	 * @return string
55
+	 */
56
+	public function getContentType()
57
+	{
58
+		return $this->contentType;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
src/Facade/ScrapePod.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
10 10
 class ScrapePod extends Facade
11 11
 {
12 12
 
13
-    /**
14
-     * @return string
15
-     */
16
-    public static function getFacadeAccessor()
17
-    {
18
-        return 'tzsk-scrape-pod';
19
-    }
13
+	/**
14
+	 * @return string
15
+	 */
16
+	public static function getFacadeAccessor()
17
+	{
18
+		return 'tzsk-scrape-pod';
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Provider/ScrapePodServiceProvider.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@
 block discarded – undo
6 6
 
7 7
 class ScrapePodServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * @return void
11
-     */
12
-    public function boot()
13
-    {
14
-        $this->app->singleton('tzsk-scrape-pod', function () {
15
-            return new ScrapePodcast();
16
-        });
17
-    }
9
+	/**
10
+	 * @return void
11
+	 */
12
+	public function boot()
13
+	{
14
+		$this->app->singleton('tzsk-scrape-pod', function () {
15
+			return new ScrapePodcast();
16
+		});
17
+	}
18 18
 
19
-    /**
20
-     * @return void
21
-     */
22
-    public function register()
23
-    {
24
-        //
25
-    }
19
+	/**
20
+	 * @return void
21
+	 */
22
+	public function register()
23
+	{
24
+		//
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function boot()
13 13
     {
14
-        $this->app->singleton('tzsk-scrape-pod', function () {
14
+        $this->app->singleton('tzsk-scrape-pod', function() {
15 15
             return new ScrapePodcast();
16 16
         });
17 17
     }
Please login to merge, or discard this patch.
src/Contracts/VendorInterface.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -5,46 +5,46 @@
 block discarded – undo
5 5
 
6 6
 interface VendorInterface
7 7
 {
8
-    /**
9
-     * @param string $value
10
-     *
11
-     * @return string
12
-     */
13
-    public function generateUrl($value);
14
-
15
-    /**
16
-     * @param array $response
17
-     *
18
-     * @return array
19
-     */
20
-    public function build(array $response);
21
-
22
-    /**
23
-     * @return void
24
-     */
25
-    public function setDefaultQuery();
26
-
27
-    /**
28
-     * @return int
29
-     */
30
-    public function getLimit();
31
-
32
-    /**
33
-     * @param int $limit
34
-     *
35
-     * @return void
36
-     */
37
-    public function setLimit($limit);
38
-
39
-    /**
40
-     * @param SimpleXMLElement $feed
41
-     *
42
-     * @return array
43
-     */
44
-    public function buildFeed(SimpleXMLElement $feed);
45
-
46
-    /**
47
-    * @return void
48
-    */
49
-    public function original();
8
+	/**
9
+	 * @param string $value
10
+	 *
11
+	 * @return string
12
+	 */
13
+	public function generateUrl($value);
14
+
15
+	/**
16
+	 * @param array $response
17
+	 *
18
+	 * @return array
19
+	 */
20
+	public function build(array $response);
21
+
22
+	/**
23
+	 * @return void
24
+	 */
25
+	public function setDefaultQuery();
26
+
27
+	/**
28
+	 * @return int
29
+	 */
30
+	public function getLimit();
31
+
32
+	/**
33
+	 * @param int $limit
34
+	 *
35
+	 * @return void
36
+	 */
37
+	public function setLimit($limit);
38
+
39
+	/**
40
+	 * @param SimpleXMLElement $feed
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function buildFeed(SimpleXMLElement $feed);
45
+
46
+	/**
47
+	 * @return void
48
+	 */
49
+	public function original();
50 50
 }
Please login to merge, or discard this patch.
src/ScrapePodcast.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,108 +7,108 @@
 block discarded – undo
7 7
 
8 8
 class ScrapePodcast
9 9
 {
10
-    /**
11
-     * @var VendorInterface
12
-     */
13
-    protected $vendor;
14
-
15
-    /**
16
-     * @var int
17
-     */
18
-    protected $count = 15;
19
-
20
-    /**
21
-    * @var bool
22
-    */
23
-    protected $isOrginal = false;
24
-
25
-    /**
26
-     * ScrapePodcast constructor.
27
-     */
28
-    public function __construct()
29
-    {
30
-        $this->vendor = new Itunes();
31
-    }
32
-
33
-    /**
34
-     * @return ScrapePodcast
35
-     */
36
-    public function itunes()
37
-    {
38
-        $this->vendor = new Itunes();
39
-
40
-        return $this;
41
-    }
42
-
43
-    /**
44
-     * @return ScrapePodcast
45
-     */
46
-    public function digitalPodcast()
47
-    {
48
-        $this->vendor = new DigitalPodcast();
49
-
50
-        return $this;
51
-    }
52
-
53
-    /**
54
-     * @param int $count
55
-     *
56
-     * @return ScrapePodcast
57
-     */
58
-    public function limit($count)
59
-    {
60
-        $this->count = $count;
61
-
62
-        return $this;
63
-    }
64
-
65
-    /**
66
-     * @param string $term
67
-     *
68
-     * @return array
69
-     */
70
-    public function search($term)
71
-    {
72
-        return $this->engine()->get($term);
73
-    }
74
-
75
-    /**
76
-     * @param $id
77
-     *
78
-     * @return array
79
-     */
80
-    public function find($id)
81
-    {
82
-        return $this->engine()->get((int) $id);
83
-    }
84
-
85
-    /**
86
-     * @param string $feed
87
-     *
88
-     * @return array
89
-     */
90
-    public function feed($feed)
91
-    {
92
-        return $this->engine()->find($feed);
93
-    }
94
-
95
-    /**
96
-     * @return ScrapePodcast
97
-     */
98
-    public function original()
99
-    {
100
-        $this->isOrginal = true;
101
-
102
-        return $this;
103
-    }
104
-
105
-    /**
106
-     * @return PodcastScraper
107
-     */
108
-    protected function engine()
109
-    {
110
-        $engine = (new PodcastScraper($this->vendor))->limit($this->count);
111
-
112
-        return $this->isOrginal ? $engine->original() : $engine;
113
-    }
10
+	/**
11
+	 * @var VendorInterface
12
+	 */
13
+	protected $vendor;
14
+
15
+	/**
16
+	 * @var int
17
+	 */
18
+	protected $count = 15;
19
+
20
+	/**
21
+	 * @var bool
22
+	 */
23
+	protected $isOrginal = false;
24
+
25
+	/**
26
+	 * ScrapePodcast constructor.
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$this->vendor = new Itunes();
31
+	}
32
+
33
+	/**
34
+	 * @return ScrapePodcast
35
+	 */
36
+	public function itunes()
37
+	{
38
+		$this->vendor = new Itunes();
39
+
40
+		return $this;
41
+	}
42
+
43
+	/**
44
+	 * @return ScrapePodcast
45
+	 */
46
+	public function digitalPodcast()
47
+	{
48
+		$this->vendor = new DigitalPodcast();
49
+
50
+		return $this;
51
+	}
52
+
53
+	/**
54
+	 * @param int $count
55
+	 *
56
+	 * @return ScrapePodcast
57
+	 */
58
+	public function limit($count)
59
+	{
60
+		$this->count = $count;
61
+
62
+		return $this;
63
+	}
64
+
65
+	/**
66
+	 * @param string $term
67
+	 *
68
+	 * @return array
69
+	 */
70
+	public function search($term)
71
+	{
72
+		return $this->engine()->get($term);
73
+	}
74
+
75
+	/**
76
+	 * @param $id
77
+	 *
78
+	 * @return array
79
+	 */
80
+	public function find($id)
81
+	{
82
+		return $this->engine()->get((int) $id);
83
+	}
84
+
85
+	/**
86
+	 * @param string $feed
87
+	 *
88
+	 * @return array
89
+	 */
90
+	public function feed($feed)
91
+	{
92
+		return $this->engine()->find($feed);
93
+	}
94
+
95
+	/**
96
+	 * @return ScrapePodcast
97
+	 */
98
+	public function original()
99
+	{
100
+		$this->isOrginal = true;
101
+
102
+		return $this;
103
+	}
104
+
105
+	/**
106
+	 * @return PodcastScraper
107
+	 */
108
+	protected function engine()
109
+	{
110
+		$engine = (new PodcastScraper($this->vendor))->limit($this->count);
111
+
112
+		return $this->isOrginal ? $engine->original() : $engine;
113
+	}
114 114
 }
Please login to merge, or discard this patch.
src/Vendors/DigitalPodcast.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -6,107 +6,107 @@
 block discarded – undo
6 6
 
7 7
 class DigitalPodcast extends AbstractVendor implements VendorInterface
8 8
 {
9
-    /**
10
-     * @var string
11
-     */
12
-    const APP_ID = "podcastsearchdemo";
13
-
14
-    /**
15
-     * @var string
16
-     */
17
-    const SEARCH_URL = "http://api.digitalpodcast.com/v2r/search";
18
-
19
-    /**
20
-     * @var string
21
-     */
22
-    const FORMAT = "rss";
23
-
24
-    /**
25
-     * @var int
26
-     */
27
-    private $limit = 15;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    private $defaultQuery = null;
33
-
34
-    /**
35
-     * DigitalPodcast constructor.
36
-     */
37
-    public function __construct()
38
-    {
39
-        $this->setDefaultQuery();
40
-    }
41
-
42
-    /**
43
-     * @return int
44
-     */
45
-    public function getLimit()
46
-    {
47
-        return $this->limit;
48
-    }
49
-
50
-    /**
51
-     * @param int $limit
52
-     */
53
-    public function setLimit($limit)
54
-    {
55
-        // `-1` being used here because the API returns 3 items when `results=2`.
56
-        $this->limit = ((int) $limit - 1);
57
-    }
58
-
59
-    /**
60
-     * @return void
61
-     */
62
-    public function setDefaultQuery()
63
-    {
64
-        $this->defaultQuery = http_build_query([
65
-            'results' => $this->limit,
66
-            'appid'   => self::APP_ID,
67
-            'format'  => self::FORMAT
68
-        ]);
69
-    }
70
-
71
-    /**
72
-     * @param  string $value
73
-     * @return string
74
-     */
75
-    public function generateUrl($value)
76
-    {
77
-        $value = urlencode($value);
78
-        $url   = self::SEARCH_URL . "?keywords={$value}";
79
-
80
-        return $url . '&' . $this->defaultQuery;
81
-    }
82
-
83
-    /**
84
-     * @param  array $response
85
-     * @return array
86
-     */
87
-    public function build(array $response)
88
-    {
89
-        $xml = new SimpleXMLElement($response['search']);
90
-        $xml = $xml->channel;
91
-
92
-        $output['result_count'] = count($xml->item);
93
-
94
-        foreach ($xml->item as $value) {
95
-            $output['results'][] = [
96
-                'title' => (string) $value->title,
97
-                'rss'   => (string) $value->source,
98
-                'link'  => (string) $value->link,
99
-            ];
100
-        }
101
-
102
-        return $output;
103
-    }
104
-
105
-    /**
106
-    * @return void
107
-    */
108
-    public function original()
109
-    {
110
-        $this->isOrginal = true;
111
-    }
9
+	/**
10
+	 * @var string
11
+	 */
12
+	const APP_ID = "podcastsearchdemo";
13
+
14
+	/**
15
+	 * @var string
16
+	 */
17
+	const SEARCH_URL = "http://api.digitalpodcast.com/v2r/search";
18
+
19
+	/**
20
+	 * @var string
21
+	 */
22
+	const FORMAT = "rss";
23
+
24
+	/**
25
+	 * @var int
26
+	 */
27
+	private $limit = 15;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	private $defaultQuery = null;
33
+
34
+	/**
35
+	 * DigitalPodcast constructor.
36
+	 */
37
+	public function __construct()
38
+	{
39
+		$this->setDefaultQuery();
40
+	}
41
+
42
+	/**
43
+	 * @return int
44
+	 */
45
+	public function getLimit()
46
+	{
47
+		return $this->limit;
48
+	}
49
+
50
+	/**
51
+	 * @param int $limit
52
+	 */
53
+	public function setLimit($limit)
54
+	{
55
+		// `-1` being used here because the API returns 3 items when `results=2`.
56
+		$this->limit = ((int) $limit - 1);
57
+	}
58
+
59
+	/**
60
+	 * @return void
61
+	 */
62
+	public function setDefaultQuery()
63
+	{
64
+		$this->defaultQuery = http_build_query([
65
+			'results' => $this->limit,
66
+			'appid'   => self::APP_ID,
67
+			'format'  => self::FORMAT
68
+		]);
69
+	}
70
+
71
+	/**
72
+	 * @param  string $value
73
+	 * @return string
74
+	 */
75
+	public function generateUrl($value)
76
+	{
77
+		$value = urlencode($value);
78
+		$url   = self::SEARCH_URL . "?keywords={$value}";
79
+
80
+		return $url . '&' . $this->defaultQuery;
81
+	}
82
+
83
+	/**
84
+	 * @param  array $response
85
+	 * @return array
86
+	 */
87
+	public function build(array $response)
88
+	{
89
+		$xml = new SimpleXMLElement($response['search']);
90
+		$xml = $xml->channel;
91
+
92
+		$output['result_count'] = count($xml->item);
93
+
94
+		foreach ($xml->item as $value) {
95
+			$output['results'][] = [
96
+				'title' => (string) $value->title,
97
+				'rss'   => (string) $value->source,
98
+				'link'  => (string) $value->link,
99
+			];
100
+		}
101
+
102
+		return $output;
103
+	}
104
+
105
+	/**
106
+	 * @return void
107
+	 */
108
+	public function original()
109
+	{
110
+		$this->isOrginal = true;
111
+	}
112 112
 }
Please login to merge, or discard this patch.
src/Vendors/Itunes.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -5,117 +5,117 @@
 block discarded – undo
5 5
 
6 6
 class Itunes extends AbstractVendor implements VendorInterface
7 7
 {
8
-    /**
9
-     * @var string
10
-     */
11
-    const SEARCH_URL = "https://itunes.apple.com/search";
12
-
13
-    /**
14
-     * @var string
15
-     */
16
-    const LOOKUP_URL = "https://itunes.apple.com/lookup";
17
-
18
-    /**
19
-     * @var string
20
-     */
21
-    const ENTITY = "podcast";
22
-
23
-    /**
24
-     * @var string
25
-     */
26
-    const MEDIA = "podcast";
27
-
28
-    /**
29
-     * @var int
30
-     */
31
-    private $limit = 15;
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    private $defaultQuery = null;
37
-
38
-    /**
39
-     * Itunes constructor.
40
-     */
41
-    public function __construct()
42
-    {
43
-        $this->setDefaultQuery();
44
-    }
45
-
46
-    /**
47
-     * @return int
48
-     */
49
-    public function getLimit()
50
-    {
51
-        return $this->limit;
52
-    }
53
-
54
-    /**
55
-     * @param int $limit
56
-     */
57
-    public function setLimit($limit)
58
-    {
59
-        $this->limit = (int) $limit;
60
-    }
61
-
62
-    /**
63
-     * @return void
64
-     */
65
-    public function setDefaultQuery()
66
-    {
67
-        $this->defaultQuery = http_build_query([
68
-            'limit'     => $this->limit,
69
-            'entity'    => self::ENTITY,
70
-            'media'     => self::MEDIA
71
-        ]);
72
-    }
73
-
74
-    /**
75
-     * @param  string $value
76
-     * @return string
77
-     */
78
-    public function generateUrl($value)
79
-    {
80
-        $value = is_string($value) ? urlencode($value) : $value;
81
-        $url   = is_int($value) ? self::LOOKUP_URL . "?id={$value}" : self::SEARCH_URL . "?term={$value}";
82
-
83
-        return $url . '&' . $this->defaultQuery;
84
-    }
85
-
86
-    /**
87
-     * @param  array  $response
88
-     * @return array
89
-     */
90
-    public function build(array $response)
91
-    {
92
-        $response = json_decode($response['search']);
93
-        if ($this->isOrginal) {
94
-            return $response;
95
-        }
96
-        $output['result_count'] = $response->resultCount;
97
-
98
-        foreach ($response->results as $value) {
99
-            $output['results'][] = [
100
-                'itunes_id' => $value->collectionId,
101
-                'author'    => $value->artistName,
102
-                'title'     => $value->collectionName,
103
-                'episodes'  => $value->trackCount,
104
-                'image'     => $value->artworkUrl600,
105
-                'rss'       => $value->feedUrl,
106
-                'itunes'    => $value->collectionViewUrl,
107
-                'genre'     => $value->primaryGenreName,
108
-            ];
109
-        }
110
-
111
-        return $output;
112
-    }
113
-
114
-    /**
115
-    * @return void
116
-    */
117
-    public function original()
118
-    {
119
-        $this->isOrginal = true;
120
-    }
8
+	/**
9
+	 * @var string
10
+	 */
11
+	const SEARCH_URL = "https://itunes.apple.com/search";
12
+
13
+	/**
14
+	 * @var string
15
+	 */
16
+	const LOOKUP_URL = "https://itunes.apple.com/lookup";
17
+
18
+	/**
19
+	 * @var string
20
+	 */
21
+	const ENTITY = "podcast";
22
+
23
+	/**
24
+	 * @var string
25
+	 */
26
+	const MEDIA = "podcast";
27
+
28
+	/**
29
+	 * @var int
30
+	 */
31
+	private $limit = 15;
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	private $defaultQuery = null;
37
+
38
+	/**
39
+	 * Itunes constructor.
40
+	 */
41
+	public function __construct()
42
+	{
43
+		$this->setDefaultQuery();
44
+	}
45
+
46
+	/**
47
+	 * @return int
48
+	 */
49
+	public function getLimit()
50
+	{
51
+		return $this->limit;
52
+	}
53
+
54
+	/**
55
+	 * @param int $limit
56
+	 */
57
+	public function setLimit($limit)
58
+	{
59
+		$this->limit = (int) $limit;
60
+	}
61
+
62
+	/**
63
+	 * @return void
64
+	 */
65
+	public function setDefaultQuery()
66
+	{
67
+		$this->defaultQuery = http_build_query([
68
+			'limit'     => $this->limit,
69
+			'entity'    => self::ENTITY,
70
+			'media'     => self::MEDIA
71
+		]);
72
+	}
73
+
74
+	/**
75
+	 * @param  string $value
76
+	 * @return string
77
+	 */
78
+	public function generateUrl($value)
79
+	{
80
+		$value = is_string($value) ? urlencode($value) : $value;
81
+		$url   = is_int($value) ? self::LOOKUP_URL . "?id={$value}" : self::SEARCH_URL . "?term={$value}";
82
+
83
+		return $url . '&' . $this->defaultQuery;
84
+	}
85
+
86
+	/**
87
+	 * @param  array  $response
88
+	 * @return array
89
+	 */
90
+	public function build(array $response)
91
+	{
92
+		$response = json_decode($response['search']);
93
+		if ($this->isOrginal) {
94
+			return $response;
95
+		}
96
+		$output['result_count'] = $response->resultCount;
97
+
98
+		foreach ($response->results as $value) {
99
+			$output['results'][] = [
100
+				'itunes_id' => $value->collectionId,
101
+				'author'    => $value->artistName,
102
+				'title'     => $value->collectionName,
103
+				'episodes'  => $value->trackCount,
104
+				'image'     => $value->artworkUrl600,
105
+				'rss'       => $value->feedUrl,
106
+				'itunes'    => $value->collectionViewUrl,
107
+				'genre'     => $value->primaryGenreName,
108
+			];
109
+		}
110
+
111
+		return $output;
112
+	}
113
+
114
+	/**
115
+	 * @return void
116
+	 */
117
+	public function original()
118
+	{
119
+		$this->isOrginal = true;
120
+	}
121 121
 }
Please login to merge, or discard this patch.