Passed
Push — develop ( dbe277...ea1e27 )
by Francisco
02:33
created

EloquentExchangeLogger::history()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Judite\Logger;
4
5
use App\Judite\Models\Enrollment;
6
use App\Judite\Models\LogExchange;
7
use App\Judite\Contracts\ExchangeLogger;
8
9
class EloquentExchangeLogger implements ExchangeLogger
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function log(Enrollment $fromEnrollment, Enrollment $toEnrollment)
15
    {
16
        $logExchange = LogExchange::make();
17
        $logExchange->fromShift()->associate($fromEnrollment->shift);
18
        $logExchange->toShift()->associate($toEnrollment->shift);
19
        $logExchange->fromStudent()->associate($fromEnrollment->student);
20
        $logExchange->toStudent()->associate($toEnrollment->student);
21
        $logExchange->save();
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function history()
28
    {
29
        return LogExchange::latest('id')->paginate();
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Judite\Models...atest('id')->paginate() returns the type Illuminate\Pagination\LengthAwarePaginator which is incompatible with the return type mandated by App\Judite\Contracts\ExchangeLogger::history() of Illuminate\Contracts\Pagination.

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...
30
    }
31
}
32