1 | <?php |
||||
2 | |||||
3 | namespace DavideCasiraghi\PhpResponsiveRandomQuote; |
||||
4 | |||||
5 | use DavideCasiraghi\PhpResponsiveRandomQuote\Models\Quote; |
||||
6 | |||||
7 | class QuoteFactory |
||||
8 | { |
||||
9 | /***************************************************************************/ |
||||
10 | |||||
11 | /** |
||||
12 | * Return a random quote. |
||||
13 | * |
||||
14 | * @return \DavideCasiraghi\PhpResponsiveRandomQuote\Models\Quote |
||||
15 | */ |
||||
16 | 1 | public function getRandomQuote() |
|||
17 | { |
||||
18 | 1 | return Quote::inRandomOrder()->first(); |
|||
19 | } |
||||
20 | |||||
21 | /***************************************************************************/ |
||||
22 | |||||
23 | /** |
||||
24 | * Return the quote of the day. |
||||
25 | * |
||||
26 | * @return \DavideCasiraghi\PhpResponsiveRandomQuote\Models\Quote |
||||
27 | */ |
||||
28 | public function getQuoteOfTheDay() |
||||
29 | { |
||||
30 | $numberOfQuotesInDB = Quote::count(); |
||||
31 | $quoteOfTheDayNumber = rand(1, $numberOfQuotesInDB); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
32 | |||||
33 | $quotes = Quote::all(); |
||||
34 | |||||
35 | return $quotes[$quoteOfTheDayNumber]; |
||||
36 | } |
||||
37 | |||||
38 | public function setCookie(Request $request) |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
39 | { |
||||
40 | $minutes = 60; |
||||
41 | $response = new Response('Set Cookie'); |
||||
0 ignored issues
–
show
|
|||||
42 | $response->withCookie(cookie('quoteOfTheDayId', 'MyValue', $minutes)); |
||||
43 | |||||
44 | return $response; |
||||
45 | } |
||||
46 | |||||
47 | public function getCookie(Request $request) |
||||
48 | { |
||||
49 | $value = $request->cookie('quoteOfTheDayId'); |
||||
50 | echo $value; |
||||
51 | } |
||||
52 | } |
||||
53 |