Parser::parseClassDocComment()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 3
nop 1
1
<?php
2
/**
3
 * This file is part of Properties package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Serafim\Properties\Parser;
11
12
use Railt\Io\File;
13
use Railt\Parser\Ast\RuleInterface;
14
15
/**
16
 * Class Parser
17
 */
18
class Parser extends BaseParser
19
{
20
    /**
21
     * @param string $class
22
     * @return RuleInterface|null
23
     */
24
    public function parseClassDocComment(string $class): ?RuleInterface
25
    {
26
        try {
27
            $comment = (new \ReflectionClass($class))->getDocComment();
28
29
            return $this->parse(File::fromSources($comment, $class));
30
        } catch (\Throwable $e) {
31
            return null;
32
        }
33
    }
34
}
35