FormatAwareTrait::setFormat()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Format;
15
16
trait FormatAwareTrait
17
{
18
    /**
19
     * @var FormatInterface|null
20
     */
21
    protected $format = null;
22
23
    /**
24
     * @return FormatInterface|null
25
     */
26 5
    public function getFormat()
27
    {
28 5
        return $this->format;
29
    }
30
31
    /**
32
     * @param FormatInterface $format
33
     *
34
     * @return $this
35
     */
36 7
    public function setFormat(FormatInterface $format)
37
    {
38 7
        $this->format = $format;
39
40 7
        return $this;
41
    }
42
43
    /**
44
     * @return null|string
45
     */
46 3
    public function getFormatType()
47
    {
48 3
        if ($this->format) {
49 2
            return $this->format->getType();
50
        }
51 1
        return null;
52
    }
53
}
54