Passed
Push — master ( e13826...b82956 )
by Sebastian
16:47 queued 09:52
created

StyleSheet   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadStyleSheet() 0 5 1
A loadLocales() 0 5 1
1
<?php
2
/**
3
 * citeproc-php
4
 *
5
 * @link        http://github.com/seboettg/citeproc-php for the source repository
6
 * @copyright   Copyright (c) 2016 Sebastian Böttger.
7
 * @license     https://opensource.org/licenses/MIT
8
 */
9
10
namespace Seboettg\CiteProc;
11
12
/**
13
 * Class StyleSheet
14
 *
15
 * Helper class for loading CSL styles and CSL locales
16
 *
17
 * @package Seboettg\CiteProc
18
 * @author Sebastian Böttger <[email protected]>
19
 */
20
class StyleSheet
21
{
22
23
    /**
24
     * Loads xml formatted CSL stylesheet of a given stylesheet name, e.g. "american-physiological-society" for
25
     * apa style.
26
     *
27
     * See in styles folder (which is included as git submodule) for all available style sheets
28
     *
29
     * @param string $styleName e.g. "american-physiological-society" for apa
30
     * @return string
31
     */
32
    public static function loadStyleSheet($styleName)
33
    {
34
        $stylesPath = __DIR__ . '/../../../styles/';
35
        return file_get_contents($stylesPath . $styleName . '.csl');
36
    }
37
38
    /**
39
     * Loads xml formatted locales of given language key
40
     *
41
     * @param string $langKey e.g. "en-US", or "de-CH"
42
     * @return string
43
     */
44
    public static function loadLocales($langKey)
45
    {
46
        $localesPath = __DIR__ . '/../../../locales/';
47
        return file_get_contents($localesPath . "locales-" . $langKey . '.xml');
48
    }
49
}