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')); |
|
|
|
|
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')); |
|
|
|
|
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')); |
|
|
|
|
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
|
|
|
} |
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..