Completed
Push — master ( 85853a...5df06c )
by James
20s queued 12s
created

ExcludeInternalProperty::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\PropertyBased;
6
7
use Roave\BackwardCompatibility\Changes;
8
use Roave\BetterReflection\Reflection\ReflectionProperty;
9
use function Safe\preg_match;
10
11
final class ExcludeInternalProperty implements PropertyBased
12
{
13
    /** @var PropertyBased */
14
    private $propertyBased;
15
16
    public function __construct(PropertyBased $propertyBased)
17
    {
18
        $this->propertyBased = $propertyBased;
19
    }
20
21
    public function __invoke(ReflectionProperty $fromProperty, ReflectionProperty $toProperty) : Changes
22
    {
23
        if ($this->isInternalDocComment($fromProperty->getDocComment())) {
24
            return Changes::empty();
25
        }
26
27
        return $this->propertyBased->__invoke($fromProperty, $toProperty);
28
    }
29
30
    private function isInternalDocComment(string $comment) : bool
31
    {
32
        return preg_match('/\s+@internal\s+/', $comment) === 1;
33
    }
34
}
35