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

_ATTR   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 35
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A table() 0 3 1
A bag() 0 18 2
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