TranslationHasBeenSet   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
1
<?php
2
3
namespace Spatie\Translatable\Events;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class TranslationHasBeenSet
8
{
9
    /** @var \Spatie\Translatable\Translatable */
10
    public $model;
11
12
    /** @var string */
13
    public $key;
14
15
    /** @var string */
16
    public $locale;
17
18
    public $oldValue;
19
    public $newValue;
20
21
    public function __construct(Model $model, $key, $locale, $oldValue, $newValue)
22
    {
23
        $this->model = $model;
0 ignored issues
show
Documentation Bug introduced by
It seems like $model of type object<Illuminate\Database\Eloquent\Model> is incompatible with the declared type object<Spatie\Translatable\Translatable> of property $model.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
25
        $this->attributeName = $key;
0 ignored issues
show
Bug introduced by
The property attributeName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
27
        $this->locale = $locale;
28
29
        $this->oldValue = $oldValue;
30
        $this->newValue = $newValue;
31
    }
32
}
33