• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHP-Alchemist / coreFiles / 15423302022

03 Jun 2025 04:58PM UTC coverage: 92.411%. First build
15423302022

Pull #9

github

druid628
CS Fixes
Pull Request #9: [Release] v3.0.0

144 of 175 new or added lines in 16 files covered. (82.29%)

548 of 593 relevant lines covered (92.41%)

4.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.93
/src/ValueObject/Abstract/AbstractVOString.php
1
<?php
2

3
namespace PHPAlchemist\ValueObject\Abstract;
4

5
use PHPAlchemist\Types\Twine;
6
use PHPAlchemist\ValueObject\Contract\VONumberInterface;
7
use PHPAlchemist\ValueObject\Contract\VOStringInterface;
8
use PHPAlchemist\ValueObject\Model\VONumber;
9

10
abstract class AbstractVOString implements VOStringInterface
11
{
12
    protected readonly string $value;
13

NEW
14
    public function __toString() : string
×
15
    {
NEW
16
        return ($this->getValue()) ?: '';
×
17
    }
18

19
    public function getValue() : ?string
4✔
20
    {
21
        return $this->value;
4✔
22
    }
23

NEW
24
    public function contains(mixed $needle, bool $caseInsensitive = false) : bool
×
25
    {
NEW
26
        if ($caseInsensitive) {
×
NEW
27
            return str_contains(mb_strtolower($this->value), mb_strtolower($needle));
×
28
        }
29

NEW
30
        return str_contains($this->value, $needle);
×
31
    }
32

33
    /** @inheritDoc */
NEW
34
    public function endsWith(mixed $needle) : bool
×
35
    {
NEW
36
        return str_ends_with($this->value, $needle);
×
37
    }
38

39
    /** @inheritDoc */
40
    public function equals(VOStringInterface $comparitive) : bool
2✔
41
    {
42
        return $comparitive->getValue() === $this->getValue();
2✔
43
    }
44

45
    /**
46
     * @inheritDoc
47
     */
NEW
48
    public function hasValue() : bool
×
49
    {
NEW
50
        return !is_null($this->value);
×
51
    }
52

53
    /** @inheritDoc */
NEW
54
    public function indexOf(string $needle, int $startIndex = 0) : int|false
×
55
    {
NEW
56
        return strpos($this->value, $needle, $startIndex);
×
57
    }
58

NEW
59
    public function lastIndexOf(string $needle, int $startIndex = 0) : int|false
×
60
    {
NEW
61
        return strrpos($this->value, $needle, $startIndex);
×
62
    }
63

64
    /**
65
     * @inheritDoc
66
     */
67
    public function length() : VONumberInterface
2✔
68
    {
69
        $length = strlen($this->value);
2✔
70

71
        return new VONumber($length);
2✔
72
    }
73

74
    /**
75
     * Convert string to lower case.
76
     *
77
     * @return string
78
     */
NEW
79
    public function lower() : string
×
80
    {
NEW
81
        return mb_strtolower($this->getValue());
×
82
    }
83

84
    /** @inheritDoc */
NEW
85
    public function startsWith(mixed $needle) : bool
×
86
    {
NEW
87
        return str_starts_with($this->value, $needle);
×
88
    }
89

90
    /** @inheritDoc */
NEW
91
    public function substring(int $offset, ?int $length = null) : VOStringInterface
×
92
    {
NEW
93
        return new Twine(substr($this->value, $offset, $length));
×
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc