Passed
Branch develop (5fc816)
by JAIME ELMER
01:58
created

Repository   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A billExist() 0 3 1
A getRepositoryPath() 0 2 1
A saveFile() 0 3 1
A cdrExist() 0 3 1
A saveBill() 0 2 1
A getBillPath() 0 3 1
A saveCdr() 0 2 1
A saveSignedBill() 0 2 1
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.1
7
 * 
8
 * Copyright 2018, Jaime Cruz
9
 */
10
11
namespace F72X;
12
13
use F72X\Company;
14
15
class Repository {
16
17
    public static function saveBill($billName, $billContent) {
18
        self::saveFile("bill/$billName.xml", $billContent);
19
    }
20
21
    public static function saveSignedBill($billName, $billContent) {
22
        self::saveFile("signedbill/S-$billName.xml", $billContent);
23
    }
24
25
    public static function saveCdr($billName, $billContent) {
26
        self::saveFile("cdr/R$billName.zip", $billContent);
27
    }
28
29
    public static function billExist($billName) {
30
        $rp = self::getRepositoryPath();
31
        return fileExists("$rp/bill/$billName.xml");
32
    }
33
34
    public static function cdrExist($billName) {
35
        $rp = self::getRepositoryPath();
36
        return fileExists("$rp/cdr/R$billName.zip");
37
    }
38
39
    public static function getRepositoryPath() {
40
        return Company::getRepositoryPath();
41
    }
42
43
    public static function getBillPath($billName) {
44
        $rp = self::getRepositoryPath();
45
        return "$rp/bill/$billName.xml";
46
    }
47
48
    private static function saveFile($filePath, $fileContent) {
49
        $rp = self::getRepositoryPath();
50
        file_put_contents("$rp/$filePath", $fileContent);
51
    }
52
53
}
54