Passed
Push — main ( 28fe2f...804823 )
by mikhail
03:26
created

Comment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 2
b 0
f 0
dl 0
loc 17
ccs 2
cts 6
cp 0.3333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A matchesPattern() 0 3 1
A hasExceededThreshold() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SavinMikhail\CommentsDensity\Comments;
6
7
use Stringable;
8
9
abstract class Comment implements Stringable
10
{
11
    protected bool $exceedThreshold = false;
12
13
    public function hasExceededThreshold(): bool
14
    {
15
        return $this->exceedThreshold;
16
    }
17
18 9
    public function matchesPattern(string $token): bool
19
    {
20 9
        return (bool) preg_match($this->getPattern(), $token);
0 ignored issues
show
Bug introduced by
The method getPattern() does not exist on SavinMikhail\CommentsDensity\Comments\Comment. Since it exists in all sub-types, consider adding an abstract or default implementation to SavinMikhail\CommentsDensity\Comments\Comment. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        return (bool) preg_match($this->/** @scrutinizer ignore-call */ getPattern(), $token);
Loading history...
21
    }
22
23
    public function __toString(): string
24
    {
25
        return $this->getName();
0 ignored issues
show
Bug introduced by
The method getName() does not exist on SavinMikhail\CommentsDensity\Comments\Comment. Since it exists in all sub-types, consider adding an abstract or default implementation to SavinMikhail\CommentsDensity\Comments\Comment. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        return $this->/** @scrutinizer ignore-call */ getName();
Loading history...
26
    }
27
}
28