Completed
Push — master ( a775f9...497487 )
by Alex
07:59
created

StandardAbstract::getFeedRuleSet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
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
namespace FeedIo;
11
12
use FeedIo\Reader\Document;
13
use FeedIo\Rule\DateTimeBuilder;
14
15
abstract class StandardAbstract
16
{
17
18
    /**
19
     * DateTime default format
20
     */
21
    const DATETIME_FORMAT = \DateTime::RFC2822;
22
23
    /**
24
     * Supported format
25
     */
26
    const SYNTAX_FORMAT = '';
27
28
    /**
29
     * @var array
30
     */
31
    protected $mandatoryFields = array();
32
33
    /**
34
     * @var \FeedIo\Rule\DateTimeBuilder
35
     */
36
    protected $dateTimeBuilder;
37
38
    /**
39
     * @param \FeedIo\Rule\DateTimeBuilder $dateTimeBuilder
40
     */
41
    public function __construct(DateTimeBuilder $dateTimeBuilder)
42
    {
43
        $this->dateTimeBuilder = $dateTimeBuilder;
44
    }
45
46
    /**
47
     * Tells if the parser can handle the feed or not
48
     * @param  Document $document
49
     * @return boolean
50 52
     */
51
    abstract public function canHandle(Document $document);
52 52
53 52
    /**
54
     * @return \FeedIo\FormatterInterface
55
     */
56
    abstract public function getFormatter();
57
58
    /**
59
     * @return string
60
     */
61
    public function getDefaultDateFormat()
62
    {
63
        return static::DATETIME_FORMAT;
64
    }
65
66
    /**
67
     * @return array
68
     */
69
    public function getMandatoryFields()
70
    {
71
        return $this->mandatoryFields;
72
    }
73
74
    /**
75
     * Returns the Format supported by the standard (XML, JSON, Text...)
76
     * @return string
77
     */
78
    public function getSyntaxFormat()
79
    {
80
        return static::SYNTAX_FORMAT;
81
    }
82
83
}
84