Completed
Push — master ( 2ce63d...389baa )
by Luis
11:05 queued 03:24
created

AttributeDocBlock   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 3 1
A getType() 0 7 2
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code\Attributes;
9
10
use PhUml\Code\DocBlock;
11
use PhUml\Code\TypeDeclaration;
12
13
/**
14
 * It used to create a type declaration for the attribute
15
 */
16
class AttributeDocBlock extends DocBlock
17
{
18
    private static $varExpression = '/@var\s*([\w]+(\[\])?)/';
19
20 54
    public static function from(string $text): AttributeDocBlock
21
    {
22 54
        return new AttributeDocBlock($text);
23
    }
24
25 54
    public function getType(): TypeDeclaration
26
    {
27 54
        $type = null;
28 54
        if (preg_match(self::$varExpression, $this->comment, $matches)) {
29 51
            $type = trim($matches[1]);
30
        }
31 54
        return TypeDeclaration::from($type);
32
    }
33
}
34