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

Repository::cdrExist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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