Formatters   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCurrent() 0 12 3
1
<?php
2
/**
3
 * Scabbia2 Formatters Component
4
 * https://github.com/eserozvataf/scabbia2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @link        https://github.com/eserozvataf/scabbia2-formatters for the canonical source repository
10
 * @copyright   2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/)
11
 * @license     http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0
12
 */
13
14
namespace Scabbia\Formatters;
15
16
use Scabbia\Formatters\FormatterInterface;
17
use Scabbia\Formatters\ConsoleFormatter;
18
use Scabbia\Formatters\HtmlFormatter;
19
20
/**
21
 * Formatters registry
22
 *
23
 * @package     Scabbia\Formatters
24
 * @author      Eser Ozvataf <[email protected]>
25
 * @since       2.0.0
26
 */
27
class Formatters
28
{
29
    /** @type FormatterInterface         $default        default formatter */
30
    public static $default = null;
31
32
33
    /**
34
     * Returns the instance of default formatter
35
     *
36
     * @return FormatterInterface default formatter
37
     */
38
    public static function getCurrent()
39
    {
40
        if (static::$default === null) {
41
            if (PHP_SAPI === "cli") {
42
                static::$default = new ConsoleFormatter();
43
            } else {
44
                static::$default = new HtmlFormatter();
45
            }
46
        }
47
48
        return static::$default;
49
    }
50
}
51