Passed
Push — master ( 0272f5...3a0c5f )
by Aleksandr
28:04 queued 25:53
created

_ATTR::bag()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2.0014

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 1
dl 0
loc 18
ccs 13
cts 14
cp 0.9286
crap 2.0014
rs 9.8666
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Enum;
11
12
use Drobotik\Eav\Interface\DefineTableInterface;
13
use Drobotik\Eav\Strategy;
14
15
class _ATTR implements DefineTableInterface
16
{
17
18
    public const ID = 'attribute_id';
19
    public const DOMAIN_ID = 'domain_id';
20
    public const NAME = 'name';
21
    public const TYPE = 'type';
22
    public const STRATEGY = 'strategy';
23
    public const SOURCE = 'source';
24
    public const DEFAULT_VALUE = 'default_value';
25
    public const DESCRIPTION = 'description';
26
27 1
    public static function table() : string
28
    {
29 1
        return 'eav_attributes';
30
    }
31
32 1
    public static function bag(string $key = null)
33
    {
34 1
        $defaults = [
35 1
            self::ID => null,
36 1
            self::NAME => null,
37 1
            self::DOMAIN_ID => null,
38 1
            self::SOURCE => null,
39 1
            self::DEFAULT_VALUE => null,
40 1
            self::DESCRIPTION => null,
41 1
            self::TYPE => ATTR_TYPE::STRING,
42 1
            self::STRATEGY => Strategy::class
43 1
        ];
44
45 1
        if (key_exists($key, $defaults)) {
46 1
            return $defaults[$key];
47
        }
48
49
        return $defaults;
50
    }
51
}
52