Completed
Push — issue/87 ( bbd942 )
by Alex
04:44
created

DateRuleAbstract::getDateTimeBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FeedIo;
12
13
use FeedIo\Rule\DateTimeBuilder;
14
15
abstract class DateRuleAbstract extends RuleAbstract
16
{
17
    /**
18
     * @var \FeedIo\Rule\DateTimeBuilder
19
     */
20
    protected $dateTimeBuilder = null;
21
22
    /**
23
     * @var string
24
     */
25
    protected $defaultFormat = \DateTime::RSS;
26
27
    /**
28
     * @param  \FeedIo\Rule\DateTimeBuilder $dateTimeBuilder
29
     * @return $this
30
     */
31 13
    public function setDateTimeBuilder(DateTimeBuilder $dateTimeBuilder)
32
    {
33 13
        $this->dateTimeBuilder = $dateTimeBuilder;
34
35 13
        return $this;
36
    }
37
38
    /**
39
     * @return DateTimeBuilder
40
     */
41 7
    public function getDateTimeBuilder()
42
    {
43 7
        if (is_null($this->dateTimeBuilder)) {
44 1
            throw new \UnexpectedValueException('date time builder should not be null');
45
        }
46
47 6
        return $this->dateTimeBuilder;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getDefaultFormat()
54
    {
55
        return $this->defaultFormat;
56
    }
57
58
    /**
59
     * @param string $defaultFormat
60
     */
61 11
    public function setDefaultFormat($defaultFormat)
62
    {
63 11
        $this->defaultFormat = $defaultFormat;
64 11
    }
65
}
66