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

keradus / PHP-CS-Fixer / 17279562118

27 Aug 2025 09:47PM UTC coverage: 94.693%. Remained the same
17279562118

push

github

keradus
CS

28316 of 29903 relevant lines covered (94.69%)

45.61 hits per line

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

92.31
/src/DocBlock/Line.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of PHP CS Fixer.
7
 *
8
 * (c) Fabien Potencier <fabien@symfony.com>
9
 *     Dariusz RumiƄski <dariusz.ruminski@gmail.com>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14

15
namespace PhpCsFixer\DocBlock;
16

17
use PhpCsFixer\Preg;
18

19
/**
20
 * This represents a line of a docblock.
21
 *
22
 * @author Graham Campbell <hello@gjcampbell.co.uk>
23
 *
24
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
25
 */
26
final class Line
27
{
28
    /**
29
     * The content of this line.
30
     */
31
    private string $content;
32

33
    /**
34
     * Create a new line instance.
35
     */
36
    public function __construct(string $content)
37
    {
38
        $this->content = $content;
61✔
39
    }
40

41
    /**
42
     * Get the string representation of object.
43
     */
44
    public function __toString(): string
45
    {
46
        return $this->content;
15✔
47
    }
48

49
    /**
50
     * Get the content of this line.
51
     */
52
    public function getContent(): string
53
    {
54
        return $this->content;
16✔
55
    }
56

57
    /**
58
     * Does this line contain useful content?
59
     *
60
     * If the line contains text or tags, then this is true.
61
     */
62
    public function containsUsefulContent(): bool
63
    {
64
        return Preg::match('/\*\s*\S+/', $this->content) && '' !== trim(str_replace(['/', '*'], ' ', $this->content));
15✔
65
    }
66

67
    /**
68
     * Does the line contain a tag?
69
     *
70
     * If this is true, then it must be the first line of an annotation.
71
     */
72
    public function containsATag(): bool
73
    {
74
        return Preg::match('/\*\s*@/', $this->content);
15✔
75
    }
76

77
    /**
78
     * Is the line the start of a docblock?
79
     */
80
    public function isTheStart(): bool
81
    {
82
        return str_contains($this->content, '/**');
15✔
83
    }
84

85
    /**
86
     * Is the line the end of a docblock?
87
     */
88
    public function isTheEnd(): bool
89
    {
90
        return str_contains($this->content, '*/');
15✔
91
    }
92

93
    /**
94
     * Set the content of this line.
95
     */
96
    public function setContent(string $content): void
97
    {
98
        $this->content = $content;
1✔
99
    }
100

101
    /**
102
     * Remove this line by clearing its contents.
103
     *
104
     * Note that this method technically brakes the internal state of the
105
     * docblock, but is useful when we need to retain the indices of lines
106
     * during the execution of an algorithm.
107
     */
108
    public function remove(): void
109
    {
110
        $this->content = '';
1✔
111
    }
112

113
    /**
114
     * Append a blank docblock line to this line's contents.
115
     *
116
     * Note that this method technically brakes the internal state of the
117
     * docblock, but is useful when we need to retain the indices of lines
118
     * during the execution of an algorithm.
119
     */
120
    public function addBlank(): void
121
    {
122
        $matched = Preg::match('/^(\h*\*)[^\r\n]*(\r?\n)$/', $this->content, $matches);
1✔
123

124
        if (!$matched) {
1✔
125
            return;
×
126
        }
127

128
        $this->content .= $matches[1].$matches[2];
1✔
129
    }
130
}
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

© 2026 Coveralls, Inc