DateIntervalFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 1
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createDateInterval() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\DateTime;
6
7
use Arp\DateTime\Exception\DateIntervalFactoryException;
8
9
final class DateIntervalFactory implements DateIntervalFactoryInterface
10
{
11
    /**
12
     * @throws DateIntervalFactoryException
13
     */
14
    public function createDateInterval(string $spec): \DateInterval
15
    {
16
        try {
17
            return new \DateInterval($spec);
18
        } catch (\Exception $e) {
19
            throw new DateIntervalFactoryException(
20
                sprintf('Failed to create a valid \DateInterval instance using \'%s\'', $spec),
21
                $e->getCode(),
22
                $e,
23
            );
24
        }
25
    }
26
}
27