TranslationHasBeenSet::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 5
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