Passed
Push — master ( 07e0f1...85dc69 )
by Attila
02:46
created

HasModuleConfig::areRoutesEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Contains the HasModuleConfig trait.
7
 *
8
 * @copyright   Copyright (c) 2021 Attila Fulop
9
 * @author      Attila Fulop
10
 * @license     MIT
11
 * @since       2021-11-11
12
 *
13
 */
14
15
namespace Konekt\Concord\Concerns;
16
17
trait HasModuleConfig
18
{
19
    public function config(string $key = null, $default = null): mixed
20
    {
21
        $key = $key ? sprintf('%s.%s', $this->getId(), $key) : $this->getId();
0 ignored issues
show
Bug introduced by
It seems like getId() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

21
        $key = $key ? sprintf('%s.%s', $this->/** @scrutinizer ignore-call */ getId(), $key) : $this->getId();
Loading history...
22
23
        return config($key, $default);
24
    }
25
26
    public function areMigrationsEnabled(): bool
27
    {
28
        return (bool) $this->config('migrations', true);
29
    }
30
31
    public function areModelsEnabled(): bool
32
    {
33
        return (bool) $this->config('models', true);
34
    }
35
36
    public function areViewsEnabled(): bool
37
    {
38
        return (bool) $this->config('views', true);
39
    }
40
41
    public function areRoutesEnabled(): bool
42
    {
43
        return (bool) $this->config('routes', true);
44
    }
45
}
46