Completed
Push — master ( 3a3730...3061b5 )
by Nikita
04:26
created

TaisiyaStyle   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B writeReplace() 0 18 5
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
     * @param $messages
14
     * @param bool $endline Whether the line is done being replaced
15
     * @param int $type
16
     */
17
    public function writeReplace($messages, bool $endline = false, int $type = self::OUTPUT_NORMAL): void
18
    {
19
        if (!is_array($messages)) {
20
            $messages = [$messages];
21
        }
22
23
        if ($endline) {
24
            foreach ($messages as $k => $text) {
25
                $messages[$k] = $text.PHP_EOL;
26
            }
27
        }
28
29
        foreach ($messages as $k => $text) {
30
            $messages[$k] = "\r\033[K".$text;
31
        }
32
33
        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...
34
    }
35
}
36