TestsCommands::getCommandTester()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ekvedaras\LaravelTestHelpers\Traits\Helpers;
6
7
use Illuminate\Console\Command;
8
use Illuminate\Foundation\Application;
9
use Symfony\Component\Console\Tester\CommandTester;
10
11
/**
12
 * Trait TestsCommands.
13
 *
14
 * @property-read Application $app
15
 */
16
trait TestsCommands
17
{
18
    /**
19
     * @param string $commandClass
20
     * @return CommandTester
21
     */
22
    protected function getCommandTester(string $commandClass): CommandTester
23
    {
24
        /** @var Command $command */
25
        $command = $this->app->make($commandClass);
26
        $command->setLaravel($this->app);
27
28
        return new CommandTester($command);
29
    }
30
}
31