Completed
Push — master ( 47a9b5...75df16 )
by Kazi Mainuddin
02:54
created

ScrapePodcast::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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 $id
72
     *
73
     * @return array
74
     */
75
    public function find($id)
76
    {
77
        return $this->engine()->get((int) $id);
78
    }
79
80
    /**
81
     * @param string $feed
82
     *
83
     * @return array
84
     */
85
    public function feed($feed)
86
    {
87
        return $this->engine()->find($feed);
88
    }
89
90
    /**
91
     * @return PodcastScraper
92
     */
93
    protected function engine()
94
    {
95
        return (new PodcastScraper($this->vendor))->limit($this->count);
96
    }
97
}
98