FormatterAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setFormatter() 0 4 1
A getFormatter() 0 7 2
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Logger
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Logger\Formatter;
16
17
/**
18
 * FormatterAwareTrait
19
 *
20
 * @package Phossa2\Logger
21
 * @author  Hong Zhang <[email protected]>
22
 * @see     FormatterAwareInterface
23
 * @version 2.0.0
24
 * @since   2.0.0 added
25
 */
26
trait FormatterAwareTrait
27
{
28
    /**
29
     * formatter
30
     *
31
     * @var    callable
32
     * @access protected
33
     */
34
    protected $formatter;
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    public function setFormatter(callable $formatter = null)
40
    {
41
        $this->formatter = $formatter;
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function getFormatter()/*# : callable */
48
    {
49
        if (is_null($this->formatter)) {
50
            $this->formatter = new DefaultFormatter();
51
        }
52
        return $this->formatter;
53
    }
54
}
55