PhpDocTag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder;
4
5
class PhpDocTag extends PhpTemplate
6
{
7
8
    public $name;
9
    public $value;
10
11
    /**
12
     * PhpDocTag constructor.
13
     * @param string $name
14
     * @param string $value
15
     */
16 13
    public function __construct($name, $value = '')
17
    {
18 13
        $this->name = $name;
19 13
        $this->value = $value;
20 13
    }
21
22 12
    protected function toString()
23
    {
24 12
        $value = trim($this->value);
25 12
        $value = $value ? ' ' . $value : '';
26 12
        if (strpos($value, "\n") !== false) {
27
            return <<<PHP
28
/**
29 2
 * @{$this->name}{$this->padLines(' * ', $value)}
30
 */
31
PHP;
32
        } else {
33
            return <<<PHP
34 12
/** @{$this->name}{$value} */
35
PHP;
36
        }
37
38
    }
39
}