Completed
Push — master ( 11f4d7...02dbf7 )
by Todd
01:44
created

MissingArgumentException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0438

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
ccs 7
cts 9
cp 0.7778
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 8
nc 2
nop 2
crap 2.0438
1
<?php
2
/**
3
 * @author Todd Burry <[email protected]>
4
 * @copyright 2009-2017 Vanilla Forums Inc.
5
 * @license MIT
6
 */
7
8
namespace Garden\Container;
9
10
/**
11
 * An exception that is thrown when a function/method is called with a missing parameter.
12
 */
13
class MissingArgumentException extends ContainerException {
14
    private $arg;
15
    private $function;
16
17
    /**
18
     * MissingArgumentException constructor.
19
     *
20
     * @param string $arg The name of the missing parameter.
21
     * @param string $function The name of the function being called, but can be empty when not known.
22
     */
23 2
    public function __construct($arg, $function = '') {
24 2
        $this->arg = $arg;
25 2
        $this->function = $function;
26
27 2
        if (empty($function)) {
28
            $message = sprintf('Missing argument $%s.', $arg);
29
        } else {
30 2
            $message = sprintf('Missing argument $%s for %s.', $arg, $function);
31
        }
32
33 2
        parent::__construct($message, 500);
34 2
    }
35
}
36