RequiredParameterMissingException::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 1
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace OniBus\Exception;
5
6
use InvalidArgumentException;
7
8
class RequiredParameterMissingException extends InvalidArgumentException
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $missing = [];
14
15
    /**
16
     * @param object $subject
17
     * @param array $missing
18
     */
19
    public function __construct($subject, array $missing)
20
    {
21
        $this->missing = $missing;
22
        parent::__construct(
23
            sprintf(
24
                "Required parameter (%s) is missing for (%s).",
25
                implode(', ', $missing),
26
                is_object($subject) ? get_class($subject) : gettype($subject)
27
            )
28
        );
29
    }
30
31
    public function getMissingParameters(): array
32
    {
33
        return $this->missing;
34
    }
35
}
36