PreResolveEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[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
namespace Webmozart\Console\Api\Event;
13
14
use Symfony\Component\EventDispatcher\Event;
15
use Webmozart\Console\Api\Application\Application;
16
use Webmozart\Console\Api\Args\RawArgs;
17
use Webmozart\Console\Api\Resolver\ResolvedCommand;
18
19
/**
20
 * Dispatched before the console arguments are resolved to a command.
21
 *
22
 * Add a listener for this event to customize the command used for the given
23
 * console arguments.
24
 *
25
 * @since  1.0
26
 *
27
 * @author Bernhard Schussek <[email protected]>
28
 */
29
class PreResolveEvent extends Event
30
{
31
    /**
32
     * @var RawArgs
33
     */
34
    private $rawArgs;
35
36
    /**
37
     * @var Application
38
     */
39
    private $application;
40
41
    /**
42
     * @var ResolvedCommand
43
     */
44
    private $resolvedCommand;
45
46
    /**
47
     * Creates the event.
48
     *
49
     * @param RawArgs     $rawArgs     The raw console arguments.
50
     * @param Application $application The application.
51
     */
52 32
    public function __construct(RawArgs $rawArgs, Application $application)
53
    {
54 32
        $this->rawArgs = $rawArgs;
55 32
        $this->application = $application;
56 32
    }
57
58
    /**
59
     * Returns the raw console arguments.
60
     *
61
     * @return RawArgs The raw console arguments.
62
     */
63 31
    public function getRawArgs()
64
    {
65 31
        return $this->rawArgs;
66
    }
67
68
    /**
69
     * Returns the application.
70
     *
71
     * @return Application The application.
72
     */
73 8
    public function getApplication()
74
    {
75 8
        return $this->application;
76
    }
77
78
    /**
79
     * Returns the resolved command.
80
     *
81
     * @return ResolvedCommand Returns the resolved command or `null` if none
82
     *                         was set.
83
     */
84 32
    public function getResolvedCommand()
85
    {
86 32
        return $this->resolvedCommand;
87
    }
88
89
    /**
90
     * Sets the resolved command.
91
     *
92
     * @param ResolvedCommand $resolvedCommand The resolved command. Set to
0 ignored issues
show
Documentation introduced by
Should the type for parameter $resolvedCommand not be null|ResolvedCommand?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
93
     *                                         `null` to let the configured
94
     *                                         resolver decide.
95
     */
96 9
    public function setResolvedCommand(ResolvedCommand $resolvedCommand = null)
97
    {
98 9
        $this->resolvedCommand = $resolvedCommand;
99 9
    }
100
}
101