Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
1 / 1
RepetitionToken
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
8 / 8
11
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getRegexStringLength
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMinimalPossibleLength
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 getMaximumPossibleLength
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toCaseInsensitive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toDotAll
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 removeStartAndEndMarkers
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2namespace Apie\RegexTools\Parts;
3
4final class RepetitionToken implements RegexPartInterface
5{
6    public function __construct(
7        public readonly RegexPartInterface $part,
8        public readonly bool $minimalOnce = false
9    ) {
10    }
11
12    public function __toString(): string
13    {
14        return $this->part . ($this->minimalOnce ? '+' : '*');
15    }
16
17    public function getRegexStringLength(): int
18    {
19        return $this->part->getRegexStringLength() + 1;
20    }
21
22    public function getMinimalPossibleLength(): int
23    {
24        return ($this->minimalOnce ? 1 : 0);
25    }
26
27    public function getMaximumPossibleLength(): ?int
28    {
29        return null;
30    }
31
32    public function toCaseInsensitive(): RegexPartInterface
33    {
34        return new RepetitionToken($this->part->toCaseInsensitive(), $this->minimalOnce);
35    }
36
37    public function toDotAll(): RegexPartInterface
38    {
39        return new RepetitionToken($this->part->toDotAll(), $this->minimalOnce);
40    }
41
42    public function removeStartAndEndMarkers(): ?RegexPartInterface
43    {
44        $part = $this->part->removeStartAndEndMarkers();
45        return $part ? new RepetitionToken($part, $this->minimalOnce) : null;
46    }
47}