Entregas   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A cep() 0 3 1
A frete() 0 7 2
A rastreio() 0 3 1
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
}