FactoryState::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

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