EventsException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongArgument() 0 5 1
A replaceMsg() 0 4 1
1
<?php
2
3
namespace NFePHP\eFinanc\Exception;
4
5
/**
6
 * Class EventsException
7
 *
8
 * @category  API
9
 * @package   NFePHP\eFinanc
10
 * @copyright Copyright (c) 2018
11
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
12
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
13
 * @link      http://github.com/nfephp-org/sped-efinanceira for the canonical source repository
14
 */
15
use NFePHP\eFinanc\Exception\ExceptionInterface;
16
17
class EventsException extends \InvalidArgumentException implements ExceptionInterface
18
{
19
    public static $list = [
20
        1000 => "Este evento [{{msg}}] não foi encontrado.",
21
        1001 => "Não foi passado o config.",
22
        1002 => "Não foram passados os dados do evento.",
23
        1003 => "Você deve passar os parâmetros de configuração num stdClass.",
24
        1004 => "JSON does not validate. Violations:\n{{msg}}",
25
        1005 => ""
26
    ];
27
    
28
    public static function wrongArgument($code, $msg = '')
29
    {
30
        $msg = self::replaceMsg(self::$list[$code], $msg);
31
        return new static($msg);
32
    }
33
    
34
    private static function replaceMsg($input, $msg)
35
    {
36
        return str_replace('{{msg}}', $msg, $input);
37
    }
38
}
39