ParseConstant   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 18 2
1
<?php
2
3
namespace Spatie\SchemaOrg\Generator\Parser\Tasks;
4
5
use Spatie\SchemaOrg\Generator\Constant;
6
use Symfony\Component\DomCrawler\Crawler;
7
8
class ParseConstant extends Task
9
{
10
    public function __invoke(): ?Constant
11
    {
12
        $node = new Crawler($this->definition);
13
14
        $constant = new Constant();
15
16
        $constant->name = preg_replace('/\s+/', '_', $this->getText($node, '[property="rdfs:label"]'));
17
18
        if (empty($constant->name)) {
19
            return null;
20
        }
21
22
        $constant->description = $this->getText($node, '[property="rdfs:comment"]');
23
24
        $constant->value = $this->getAttribute($node, 'resource');
25
26
        return $constant;
27
    }
28
}
29