Passed
Push — master ( feac44...0272f5 )
by Aleksandr
33:21
created

_ATTR::table()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
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 1
27
    public static function table() : string
28 1
    {
29
        return 'eav_attributes';
30
    }
31 1
32
    public static function bag(string $key = null)
33 1
    {
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
        ];
44
45 1
        if (key_exists($key, $defaults)) {
46
            return $defaults[$key];
47 1
        }
48 1
49 1
        return $defaults;
50 1
    }
51
}
52