Completed
Push — master ( 898a1e...1e4799 )
by PROSPER
01:55
created

Quotes::blessUp()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 3
eloc 6
nc 3
nop 0
1
<?php
2
3
namespace Unicodeveloper\Quotes;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Support\Collection;
7
8
class Quotes {
9
10
    /**
11
     * Quotes
12
     * @var collection
13
     */
14
    protected $quotes;
15
16
    /**
17
     * Get the Quotes from the respective files depending on the Category
18
     * @param  string $category
19
     * @return array
20
     */
21
    private function getQuotes($category = null)
22
    {
23
        if(is_null($category)) {
24
            return require_once("Quotes/programming.php");
25
        }
26
27
        return require_once("Quotes/{$category}.php");
28
    }
29
30
    /**
31
     * Transform the programming quotes into a Collection
32
     * @return Unicodeveloper\Quotes\Quotes
33
     */
34
    public function programming()
35
    {
36
        $this->quotes = Collection::make($this->getQuotes('programming'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Coll...tQuotes('programming')) of type object<Illuminate\Support\Collection> is incompatible with the declared type object<Unicodeveloper\Quotes\collection> of property $quotes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
38
        return $this;
39
    }
40
41
    /**
42
     * Transform all the design quotes into a Collection
43
     * @return Unicodeveloper\Quotes\Quotes
44
     */
45
    public function design()
46
    {
47
        $this->quotes = Collection::make($this->getQuotes('design'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Coll...s->getQuotes('design')) of type object<Illuminate\Support\Collection> is incompatible with the declared type object<Unicodeveloper\Quotes\collection> of property $quotes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
49
        return $this;
50
    }
51
52
    /**
53
     * Get all Djkhaled Keys To Success #BlessUp #AnotherOne #TheyDontWantMeToWriteThisPackage
54
     * @return Unicodeveloper\Quotes\Quotes
55
     */
56
    public function djkhaled()
57
    {
58
        $this->quotes = Collection::make($this->getQuotes('djkhaled'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Illuminate\Support\Coll...>getQuotes('djkhaled')) of type object<Illuminate\Support\Collection> is incompatible with the declared type object<Unicodeveloper\Quotes\collection> of property $quotes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
60
        return $this;
61
    }
62
63
    /**
64
     * Get another quote. Another one, I say, Another One #BlessUp
65
     * @return string
66
     */
67
    public function anotherOne()
68
    {
69
        return $this->quotes->random();
70
    }
71
72
    /**
73
     * Get a random quote
74
     * @return string
75
     */
76
    public function random()
77
    {
78
        return $this->quotes->random();
79
    }
80
81
    /**
82
     * Get all the quotes
83
     * @return Illuminate\Support\Collection
84
     */
85
    public function all()
86
    {
87
        return $this->quotes->all();
88
    }
89
90
    /**
91
     * Get all the Keys to Success that are Blessed Up!
92
     * @return array
93
     */
94
    public function blessUp()
95
    {
96
        $blessUp = [];
97
98
        foreach($this->quotes->all() as $keys => $success) {
99
            if(preg_match('/\bbless up\b/i', $success)) {
100
                array_push($blessUp, $success);
101
            }
102
        }
103
104
        return $blessUp;
105
    }
106
107
}