TaisiyaStyle::writeReplace()   B
last analyzed

Complexity

Conditions 5
Paths 10

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 10
nop 3
1
<?php
2
3
namespace Taisiya\CoreBundle\Console\Style;
4
5
use Symfony\Component\Console\Style\SymfonyStyle;
6
7
class TaisiyaStyle extends SymfonyStyle
8
{
9
    /**
10
     * Outputs a replacable line to the cli.
11
     * You can continue replacing the line until TRUE is passed as the second parameter
12
     * in order to indicate you are done modifying the line.
13
     *
14
     * @param $messages
15
     * @param bool $endline Whether the line is done being replaced
16
     * @param int  $type
17
     */
18
    public function writeReplace($messages, bool $endline = false, int $type = self::OUTPUT_NORMAL): void
19
    {
20
        if (!is_array($messages)) {
21
            $messages = [$messages];
22
        }
23
24
        if ($endline) {
25
            foreach ($messages as $k => $text) {
26
                $messages[$k] = $text.PHP_EOL;
27
            }
28
        }
29
30
        foreach ($messages as $k => $text) {
31
            $messages[$k] = "\r\033[K".$text;
32
        }
33
34
        parent::write($messages, false, $type);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (write() instead of writeReplace()). Are you sure this is correct? If so, you might want to change this to $this->write().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
35
    }
36
}
37