YamlFormatter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A write() 0 9 1
1
<?php
2
namespace Consolidation\OutputFormatters\Formatters;
3
4
use Symfony\Component\Yaml\Yaml;
5
use Consolidation\OutputFormatters\Options\FormatterOptions;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Yaml formatter
10
 *
11
 * Convert an array or ArrayObject into Yaml.
12
 */
13
class YamlFormatter implements FormatterInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18 2
    public function write(OutputInterface $output, $data, FormatterOptions $options)
19
    {
20
        // Set Yaml\Dumper's default indentation for nested nodes/collections to
21
        // 2 spaces for consistency with Drupal coding standards.
22 2
        $indent = 2;
23
        // The level where you switch to inline YAML is set to PHP_INT_MAX to
24
        // ensure this does not occur.
25 2
        $output->writeln(Yaml::dump($data, PHP_INT_MAX, $indent, false, true));
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Unused Code introduced by
The call to Yaml::dump() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
26 2
    }
27
}
28