Completed
Pull Request — master (#33)
by Tom
02:24
created

ExceptionFactory::optionsToString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace TomPHP\ConfigServiceProvider\Exception;
4
5
trait ExceptionFactory
6
{
7
    /**
8
     * @param string $message
9
     * @param mixed  ...$params
10
     *
11
     * @return self
12
     */
13
    protected static function create($message)
14
    {
15
        $params = func_get_args();
16
        array_shift($params);
17
18
        return new self(vsprintf($message, $params));
0 ignored issues
show
Unused Code introduced by
The call to ExceptionFactory::__construct() has too many arguments starting with vsprintf($message, $params).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
19
    }
20
21
    /**
22
     * @param string[] $options
23
     *
24
     * @return string
25
     */
26
    protected static function optionsToString(array $options)
27
    {
28
        if (empty($options)) {
29
            return '[]';
30
        }
31
32
        return '["' . implode('", "', $options) . '"]';
33
    }
34
}
35