DocBlockWrapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDocTag() 0 3 1
A hasDocTag() 0 3 1
A getDocTags() 0 10 2
1
<?php
2
3
namespace AlexWells\ApiDocsGenerator\Parsers;
4
5
use Mpociot\Reflection\DocBlock;
6
use Illuminate\Support\Collection;
7
use Mpociot\Reflection\DocBlock\Tag;
8
9
class DocBlockWrapper extends DocBlock
10
{
11
    /**
12
     * Returns doc tags by name (ignore case).
13
     *
14
     * @param string $name
15
     *
16
     * @return Collection|Tag[]
17
     */
18
    public function getDocTags($name = null)
19
    {
20
        $tags = collect($this->getTags());
21
22
        if ($name === null) {
23
            return $tags;
24
        }
25
26
        return $tags->filter(function (Tag $tag) use ($name) {
27
            return strtolower($tag->getName()) === strtolower($name);
28
        });
29
    }
30
31
    /**
32
     * Returns doc tag by name (ignore case).
33
     *
34
     * @param string $name
35
     *
36
     * @return Tag
37
     */
38
    public function getDocTag($name)
39
    {
40
        return $this->getDocTags($name)->first();
41
    }
42
43
    /**
44
     * Checks if doc contains specified tag (ignore case).
45
     *
46
     * @param string $name
47
     *
48
     * @return bool
49
     */
50
    public function hasDocTag($name)
51
    {
52
        return $this->getDocTags($name)->isNotEmpty();
53
    }
54
}
55