FactoryState   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 16 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: igor
5
 * Date: 12/06/18
6
 * Time: 16:47
7
 */
8
9
namespace AdminWeb\PayerPagSeguro\States;
10
11
use AdminWeb\Payer\States\StateException;
12
13
class FactoryState
14
{
15
    static public function get($state)
16
    {
17
        $states = [
18
            WaitingPayment::CODE => new WaitingPayment(),
19
            InAnalysis::CODE => new InAnalysis(),
20
            PaidState::CODE => new PaidState(),
21
            AvailableState::CODE => new AvailableState(),
22
            ContestState::CODE => new ContestState(),
23
            ReturnedState::CODE => new ReturnedState(),
24
            CancelledState::CODE => new CancelledState(),
25
            DebitedState::CODE => new DebitedState()
26
        ];
27
        if (!array_key_exists($state, $states)) {
28
            throw new StateException('Unknow State');
29
        }
30
        return $states[$state];
31
    }
32
}