Test Failed
Push — ft/fields-refactor ( a46930...c631a4 )
by Ben
33:55
created

SettingFieldsManager::fieldValue()   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
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Thinktomorrow\Chief\Settings;
4
5
use Illuminate\Http\Request;
6
use Thinktomorrow\Chief\Fields\Fields;
7
use Thinktomorrow\Chief\Fields\FieldManager;
8
use Thinktomorrow\Chief\Fields\RenderingFields;
9
use Thinktomorrow\Chief\Fields\Types\Field;
10
use Thinktomorrow\Chief\Fields\Types\InputField;
11
12
class SettingFieldsManager extends Fields implements FieldManager
13
{
14
    use RenderingFields;
0 ignored issues
show
Bug introduced by
The trait Thinktomorrow\Chief\Fields\RenderingFields requires the property $model which is not provided by Thinktomorrow\Chief\Settings\SettingFieldsManager.
Loading history...
15
16
    /** @var Settings */
17
    private $settingsManager;
18
19
    public function __construct(Settings $settingsManager)
20
    {
21
        $this->settingsManager = $settingsManager;
22
    }
23
24
    public function fields(): Fields
25
    {
26
        return new Fields([
27
            InputField::make('client.app_name')
28
                ->label('Site naam')
0 ignored issues
show
Bug introduced by
The method label() does not exist on Thinktomorrow\Chief\Fields\Types\InputField. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
                ->/** @scrutinizer ignore-call */ label('Site naam')
Loading history...
29
                ->description('Naam van de applicatie. Dit wordt getoond in o.a. de mail communicatie.')
0 ignored issues
show
Bug introduced by
The method description() does not exist on Thinktomorrow\Chief\Fields\Types\InputField. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
                ->/** @scrutinizer ignore-call */ description('Naam van de applicatie. Dit wordt getoond in o.a. de mail communicatie.')
Loading history...
30
                ->translatable(['nl' => 'nl', 'fr' => 'fr']),
31
            InputField::make('contact.email')
32
                ->label('Webmaster email')
33
                ->description('Het emailadres van de webmaster. Hierop ontvang je standaard alle contactnames.'),
34
            InputField::make('contact.name')
35
                ->label('Webmaster naam')
36
                ->description('Voor en achternaam van de webmaster.'),
37
        ]);
38
    }
39
40
    public function fieldValue(Field $field, $locale = null)
41
    {
42
        return $this->settingsManager->get($field->key(), $locale);
0 ignored issues
show
Bug introduced by
The method key() does not exist on Thinktomorrow\Chief\Fields\Types\Field. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        return $this->settingsManager->get($field->/** @scrutinizer ignore-call */ key(), $locale);
Loading history...
43
    }
44
45
    public function saveFields(Request $request)
46
    {
47
        ddd($request->all());
48
    }
49
}