Passed
Push — master ( 463105...84cd59 )
by Roberto
04:47
created

Oids::getOid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
namespace NFePHP\Common\Certificate;
4
5
/**
6
 * Class to obtain the list of OID Object Identifier of encrypted data
7
 * contained in a digital certificate.
8
 * See Oid from Abstract Syntax Notation One (ASN.1) for
9
 * Distinguished Encoding Rules (DER)
10
 * @category   NFePHP
11
 * @package    NFePHP\Common\Certificate\Oids
12
 * @copyright  Copyright (c) 2008-2016
13
 * @license    http://www.gnu.org/licenses/lesser.html LGPL v3
14
 * @author     Roberto L. Machado <linux.rlm at gmail dot com>
15
 * @link       http://github.com/nfephp-org/nfephp for the canonical source repository
16
 */
17
18
class Oids
19
{
20
    /**
21
     * @var array
22
     */
23
    private static $oidsTable = array();
24
            
25
    /**
26
     * Return Oid name
27
     * @param string $key formated OID numeric key
28
     * @return string
29
     */
30
    public static function getOid($key)
31
    {
32
        self::loadOids();
33
        if (array_key_exists($key, self::$oidsTable)) {
34
            return self::$oidsTable[$key];
35
        }
36
        return '';
37
    }
38
    
39
    /**
40
     * Returns all oids in the list
41
     * @return array
42
     */
43
    public static function listOids()
44
    {
45
        self::loadOids();
46
        return self::$oidsTable;
47
    }
48
    
49
    /**
50
     * Load list of oids
51
     */
52
    private static function loadOids()
53
    {
54
        $json = file_get_contents(__DIR__ .'/oids.json');
55
        self::$oidsTable = (array) json_decode($json, true);
56
    }
57
}
58