Quotes::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Laravel Quotes package.
5
 *
6
 * (c) Prosper Otemuyiwa <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Unicodeveloper\Quotes;
13
14
use GuzzleHttp\Client;
15
use Illuminate\Support\Collection;
16
17
class Quotes {
18
19
    /**
20
     * Quotes
21
     * @var collection
22
     */
23
    protected $quotes;
24
25
    /**
26
     * Get the Quotes from the respective files depending on the Category
27
     * @param  string $category
28
     * @return array
29
     */
30
    private function getQuotes($category = null)
31
    {
32
        if(is_null($category)) {
33
            return require("Quotes/programming.php");
34
        }
35
36
        return require("Quotes/{$category}.php");
37
    }
38
39
    /**
40
     * Transform the programming quotes into a Collection
41
     * @return Unicodeveloper\Quotes\Quotes
42
     */
43
    public function programming()
44
    {
45
        $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...
46
47
        return $this;
48
    }
49
50
    /**
51
     * Transform all the design quotes into a Collection
52
     * @return Unicodeveloper\Quotes\Quotes
53
     */
54
    public function design()
55
    {
56
        $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...
57
58
        return $this;
59
    }
60
61
    /**
62
     * Get all Djkhaled Keys To Success #BlessUp #AnotherOne #TheyDontWantMeToWriteThisPackage
63
     * @return Unicodeveloper\Quotes\Quotes
64
     */
65
    public function djkhaled()
66
    {
67
        $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...
68
69
        return $this;
70
    }
71
72
    /**
73
     * Get another quote. Another one, I say, Another One #BlessUp
74
     * @return string
75
     */
76
    public function anotherOne()
77
    {
78
        return $this->quotes->random();
79
    }
80
81
    /**
82
     * Get a random quote
83
     * @return string
84
     */
85
    public function random()
86
    {
87
        return $this->quotes->random();
88
    }
89
90
    /**
91
     * Get all the quotes
92
     * @return Illuminate\Support\Collection
93
     */
94
    public function all()
95
    {
96
        return $this->quotes->all();
97
    }
98
99
    /**
100
     * Get all the Keys to Success that are Blessed Up!
101
     * @return array
102
     */
103
    public function blessUp()
104
    {
105
        $blessUp = [];
106
107
        foreach($this->quotes->all() as $keys => $success) {
108
            if(preg_match('/\bbless up\b/i', $success)) {
109
                array_push($blessUp, $success);
110
            }
111
        }
112
113
        return $blessUp;
114
    }
115
116
}