Completed
Push — master ( e7d66f...77a53e )
by Roberto
04:50 queued 02:26
created

SoapCode::info()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2.032
1
<?php
2
3
namespace NFePHP\Common\Soap;
4
5
/**
6
 * SoapCode return a description os HTTP Codes returned from server
7
 * useful to help identify the cause of the communication problem,
8
 * either with a SOAP server or a server RESTFUL
9
 * The codes and their descriptions are stored in a json file in the same folder
10
 *
11
 * @category  NFePHP
12
 * @package   NFePHP\Common\Soap\SoapCode
13
 * @copyright NFePHP Copyright (c) 2016
14
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
15
 * @license   https://opensource.org/licenses/MIT MIT
16
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
17
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
18
 * @link      http://github.com/nfephp-org/sped-common for the canonical source repository
19
 */
20
21
class SoapCode
22
{
23 1
    public static function info($code)
24
    {
25 1
        $codes = (array) json_decode(file_get_contents(__DIR__.'/httpcodes.json'), true);
26 1
        if (array_key_exists($code, $codes)) {
27 1
            return $codes[$code];
28
        }
29
        return ['level' => 'Desconhecido', 'description' => 'Desconhecido', 'means' => 'Desconhecido'];
30
    }
31
}
32