Passed
Push — master ( 2564c1...9453fd )
by Orkhan
02:47
created

Currency::rate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 2
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\HasMany;
7
8
class Currency extends Model
9
{
10
    protected $table = 'currencylayer_currencies';
11
12
    public $timestamps = false;
13
14
    protected $fillable = [
15
        'name',
16
        'code',
17
    ];
18
19
    public function rates(): HasMany
20
    {
21
        return $this->hasMany(Rate::class, 'source_currency_id');
22
    }
23
24
    public function rate(Currency $target, $date = null)
0 ignored issues
show
Unused Code introduced by
The parameter $date 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

24
    public function rate(Currency $target, /** @scrutinizer ignore-unused */ $date = null)

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...
25
    {
26
        return $this->targetRates()->where('target_currency_id', $target->id)->orderByDesc('rate_for')->first();
27
    }
28
}
29