Issues (7)

src/QuoteFactory.php (4 issues)

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
It seems like $numberOfQuotesInDB can also be of type Illuminate\Database\Eloquent\Builder; however, parameter $max of rand() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        $quoteOfTheDayNumber = rand(1, /** @scrutinizer ignore-type */ $numberOfQuotesInDB);
Loading history...
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 ignore-unused  annotation

38
    public function setCookie(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The type DavideCasiraghi\PhpResponsiveRandomQuote\Request was not found. Did you mean Request? If so, make sure to prefix the type with \.
Loading history...
39
    {
40
        $minutes = 60;
41
        $response = new Response('Set Cookie');
0 ignored issues
show
The type DavideCasiraghi\PhpResponsiveRandomQuote\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
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