Passed
Push — master ( 17e6cc...350d8b )
by Aleksandr
41:29 queued 06:24
created

AttributeException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
c 0
b 0
f 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A undefinedAttributeName() 0 3 1
A unsupportedType() 0 3 1
A undefinedAttributeType() 0 3 1
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\Exception;
11
12
use Exception;
13
14
class AttributeException extends Exception
15
{
16
    public const UNDEFINED_NAME = 'Attribute name must be provided!';
17
    public const UNDEFINED_TYPE = 'Attribute type must be provided!';
18
    public const UNSUPPORTED_TYPE = 'Type is not supported: %s';
19
20
    /**
21
     * @throws AttributeException
22
     */
23 1
    public static function undefinedAttributeName()
24
    {
25 1
        throw new static(self::UNDEFINED_NAME);
26
    }
27
28
    /**
29
     * @throws AttributeException
30
     */
31 1
    public static function undefinedAttributeType()
32
    {
33 1
        throw new static(self::UNDEFINED_TYPE);
34
    }
35
36
    /**
37
     * @throws AttributeException
38
     */
39 1
    public static function unsupportedType($type)
40
    {
41 1
        throw new static(sprintf(self::UNSUPPORTED_TYPE, $type));
42
    }
43
}