Passed
Push — add-option-to-change-output ( 0c1513 )
by Shinji
03:29
created

TraceOutputFactory::fromSettingsAndConsoleOutput()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 7
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 13
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Inspector\Output\TraceOutput;
15
16
use PhpProfiler\Inspector\Output\OutputChannel\ConsoleOutputChannel;
17
use PhpProfiler\Inspector\Output\TraceFormatter\Templated\TraceFormatterFactory;
18
use PhpProfiler\Inspector\Settings\OutputSettings\OutputSettings;
19
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\OutputInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Symfony\Component\Console\Output\StreamOutput;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Output\StreamOutput was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
class TraceOutputFactory
23
{
24
    public function __construct(
25
        private TraceFormatterFactory $trace_formatter_factory,
26
    ) {
27
    }
28
29
    public function fromSettingsAndConsoleOutput(
30
        OutputInterface $output,
31
        OutputSettings $output_settings,
32
    ): TraceOutput {
33
        if (!is_null($output_settings->output_path)) {
34
            $output = new StreamOutput(
35
                fopen($output_settings->output_path, 'w', false)
36
            );
37
        }
38
        return new FormattedTraceOutput(
39
            new ConsoleOutputChannel($output),
40
            $this->trace_formatter_factory->createFromSettings(
41
                $output_settings
42
            )
43
        );
44
    }
45
}
46