Dic::appendComment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
namespace DicDoc;
3
4
5
use DicDoc\Interfaces\CallerPositionFinder;
6
7
/**
8
 * Class Dic
9
 *
10
 * @package DicDoc
11
 */
12
class Dic
13
{
14
15
    /**
16
     * @var CallerPositionFinder
17
     */
18
    public $callerFinder;
19
    /**
20
     * @var array
21
     */
22
    public static $fileOffset = [];
23
    /**
24
     * @var Documentator
25
     */
26
    public static $documentator;
27
28
    /**
29
     * Dic constructor.
30
     *
31
     * @param CallerPositionFinder $callerFinder
32
     * @param Documentator         $documentator
33
     */
34
    public function __construct(CallerPositionFinder $callerFinder, Documentator $documentator)
35
    {
36
        $this->callerFinder = $callerFinder;
37
        self::$documentator = $documentator;
38
    }
39
40
    /**
41
     * @param $param
42
     */
43
    public function doc($param)
44
    {
45
        $callerPosition = $this->callerFinder->getCallerPosition();
46
        $filePath = $callerPosition->getFile();
47
        isset(self::$fileOffset[$filePath]) ? self::$fileOffset[$filePath]++ : self::$fileOffset[$filePath] = 0;
48
        register_shutdown_function(
49
            [DIC::class, 'appendComment'],
50
            new ParameterInformation($param),
51
            $callerPosition,
52
            self::$fileOffset[$filePath]
53
        );
54
    }
55
56
    /**
57
     * @param ParameterInformation $parameterInformation
58
     * @param CallerPosition       $callerPosition
59
     * @param                      $offset
60
     */
61
    public static function appendComment(
62
        ParameterInformation $parameterInformation,
63
        CallerPosition $callerPosition,
64
        $offset
65
    ) {
66
        self::$documentator->document($parameterInformation, $callerPosition, $offset);
67
    }
68
}