Passed
Branch master (2530fd)
by Kazi Mainuddin
03:16
created

ScrapePodcast   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 80
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A itunes() 0 6 1
A digitalPodcast() 0 6 1
A limit() 0 6 1
A search() 0 4 1
A feed() 0 4 1
A engine() 0 4 1
1
<?php
2
namespace Tzsk\ScrapePod;
3
4
use Tzsk\ScrapePod\Contracts\VendorInterface;
5
use Tzsk\ScrapePod\Vendors\DigitalPodcast;
6
use Tzsk\ScrapePod\Vendors\Itunes;
7
8
class ScrapePodcast
9
{
10
	/**
11
	 * @var VendorInterface
12
	 */
13
	protected $vendor;
14
15
	/**
16
	 * @var int
17
	 */
18
	protected $count = 15;
19
20
	/**
21
	 * ScrapePodcast constructor.
22
	 */
23
	public function __construct()
24
	{
25
		$this->vendor = new Itunes();
26
	}
27
28
	/**
29
	 * @return ScrapePodcast
30
	 */
31
	public function itunes()
32
	{
33
		$this->vendor = new Itunes();
34
35
		return $this;
36
	}
37
38
	/**
39
	 * @return ScrapePodcast
40
	 */
41
	public function digitalPodcast()
42
	{
43
		$this->vendor = new DigitalPodcast();
44
45
		return $this;
46
	}
47
48
	/**
49
	 * @param int $count
50
	 *
51
	 * @return ScrapePodcast
52
	 */
53
	public function limit($count)
54
	{
55
		$this->count = $count;
56
57
		return $this;
58
	}
59
60
	/**
61
	 * @param string $term
62
	 *
63
	 * @return array
64
	 */
65
	public function search($term)
66
	{
67
		return $this->engine()->get($term);
68
	}
69
70
	/**
71
	 * @param string $feed
72
	 *
73
	 * @return array
74
	 */
75
	public function feed($feed)
76
	{
77
		return $this->engine()->find($feed);
78
	}
79
80
	/**
81
	 * @return PodcastScraper
82
	 */
83
	protected function engine()
84
	{
85
		return (new PodcastScraper($this->vendor))->limit($this->count);
86
	}
87
}