Entregas::frete()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 4
1
<?php
2
3
namespace ThallesDKoester\Entregas;
4
5
use Exception;
6
7
/**
8
 * Thalles D. Koester | Class Entregas
9
 *
10
 * @author  Thalles D. koester <[email protected]>
11
 * @package ThallesDKoester\Entregas
12
 */
13
class Entregas
14
{
15
    const FRETE_FORMATO_CAIXA = 1;
16
    const FRETE_FORMATO_ROLO = 2;
17
    const FRETE_FORMATO_ENVELOPE = 3;
18
19
    /**
20
     * @param string $cep
21
     * @return Cep
22
     */
23
    public static function cep(string $cep): Cep
24
    {
25
        return new Cep($cep);
26
    }
27
28
    /**
29
     * @param array      $zipcode
30
     * @param array      $methods
31
     * @param array      $item
32
     * @param array|null $options
33
     * @return Frete|null
34
     */
35
    public static function frete(array $zipcode, array $methods, array $item, ?array $options = null): ?Frete
36
    {
37
        try {
38
            return new Frete($zipcode, $methods, $item, $options);
39
        } catch (Exception $e) {
40
            trigger_error($e, E_USER_WARNING);
41
            return null;
42
        }
43
    }
44
45
46
    /**
47
     * @param string     $code
48
     * @param array|null $options
49
     * @return Rastreio
50
     */
51
    public static function rastreio(string $code, ?array $options = []): Rastreio
52
    {
53
        return new Rastreio($code, $options);
54
    }
55
}