SchemaLocationPartsNotEvenException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 44
ccs 9
cts 9
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getParts() 0 3 1
A getPartsAsString() 0 3 1
A __construct() 0 4 1
A create() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Eclipxe\XmlSchemaValidator\Exceptions;
6
7
use RuntimeException;
8
9
final class SchemaLocationPartsNotEvenException extends RuntimeException implements XmlSchemaValidatorException
10
{
11
    /** @var string[] */
12
    private $parts;
13
14
    /**
15
     * SchemaLocationPartsNotEvenException constructor.
16
     *
17
     * @param string $message
18
     * @param string[] $parts
19
     */
20 1
    private function __construct(string $message, array $parts)
21
    {
22 1
        parent::__construct($message);
23 1
        $this->parts = $parts;
24
    }
25
26
    /**
27
     * @param string[] $parts
28
     * @return self
29
     */
30 1
    public static function create(array $parts): self
31
    {
32 1
        return new self('The schemaLocation attribute does not have even parts', $parts);
33
    }
34
35
    /**
36
     * Return the parts found on the schemaLocations attribute
37
     *
38
     * @return string[]
39
     */
40 1
    public function getParts(): array
41
    {
42 1
        return $this->parts;
43
    }
44
45
    /**
46
     * Return the parts found on the schemaLocations attribute separated by a space
47
     *
48
     * @return string
49
     */
50 1
    public function getPartsAsString(): string
51
    {
52 1
        return implode(' ', $this->parts);
53
    }
54
}
55