Passed
Pull Request — master (#349)
by
unknown
03:46
created

PostScriptGlyphs   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCodePoint() 0 3 1
A getGlyphs() 0 7 2
1
<?php
2
3
/**
4
 * @file This file is part of the PdfParser library.
5
 *
6
 * @author  Dāvis Mosāns <[email protected]>
7
 * @date    2019-09-17
8
 *
9
 * @license LGPLv3
10
 * @url     <https://github.com/smalot/pdfparser>
11
 *
12
 *  PdfParser is a pdf library written in PHP, extraction oriented.
13
 *  Copyright (C) 2017 - Sébastien MALOT <[email protected]>
14
 *
15
 *  This program is free software: you can redistribute it and/or modify
16
 *  it under the terms of the GNU Lesser General Public License as published by
17
 *  the Free Software Foundation, either version 3 of the License, or
18
 *  (at your option) any later version.
19
 *
20
 *  This program is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU Lesser General Public License for more details.
24
 *
25
 *  You should have received a copy of the GNU Lesser General Public License
26
 *  along with this program.
27
 *  If not, see <http://www.pdfparser.org/sites/default/LICENSE.txt>.
28
 */
29
30
namespace Smalot\PdfParser\Encoding;
31
32
/**
33
 * Class PostScriptGlyphs
34
 */
35
class PostScriptGlyphs
36
{
37
    private static $glyphs = null;
38
39
    /**
40
     * @return array
41
     *
42
     * The mapping tables have been converted from https://github.com/OpenPrinting/cups-filters/blob/master/fontembed/aglfn13.c,
43
     * part of the OpenPrinting/cups-filters package, which itself is licensed under the MIT license and lists this specific code part as:
44
     * Copyright 2008,2012 Tobias Hoffmann under the Expat license (https://www.gnu.org/licenses/license-list.html#Expat)
45
     */
46 1
    public static function getGlyphs()
47
    {
48 1
        if (null === self::$glyphs) {
49 1
            self::$glyphs = json_decode(file_get_contents(__DIR__.'/PostScriptGlyphs.json'), true);
50
        }
51
52 1
        return self::$glyphs;
53
    }
54
55 1
    public static function getCodePoint($glyph)
56
    {
57 1
        return hexdec(static::getGlyphs()[$glyph]);
58
    }
59
}
60