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

ExcludeInternalProperty   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
A __construct() 0 3 1
A isInternalDocComment() 0 3 1
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