Passed
Push — master ( 6ffe87...662eee )
by Mattia
03:26
created

AccountStatsRepository::incrementRequestCounter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Repositories;
6
7
use App\Models\AccountStats;
8
use Czim\Repository\BaseRepository;
9
10
/**
11
 * Class AccountStatsRepository.
12
 */
13
class AccountStatsRepository extends BaseRepository
14
{
15
    public function model(): string
16
    {
17
        return AccountStats::class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Models\AccountStats::class returns the type string which is incompatible with the return type mandated by Czim\Repository\Contract...itoryInterface::model() of Illuminate\Database\Eloquent\Model.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
18
    }
19
20
    /**
21
     * Increment request counter.
22
     *
23
     * @param string $uuid User UUID
24
     */
25
    public function incrementRequestCounter(string $uuid = ''): void
26
    {
27
        $this->query()
28
            ->where('uuid', $uuid)
29
            ->update([
30
                'count_request' => app('db')->raw('count_request + 1'),
31
                'time_request' => \time(),
32
            ]);
33
    }
34
}
35