_ATTR::table()   A
last analyzed

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