Test Failed
Pull Request — master (#9)
by Darío
02:32
created

Environment   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 3
Bugs 2 Features 1
Metric Value
wmc 8
eloc 12
c 3
b 2
f 1
dl 0
loc 44
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getEndpoint() 0 3 1
A isCheckoutActivated() 0 3 1
A getCurrentEnvironment() 0 3 1
A areSubscriptionsActivated() 0 3 1
A isSandbox() 0 3 1
A getSecret() 0 3 1
A isLive() 0 3 1
A getClientId() 0 3 1
1
<?php
2
3
namespace Pleets\LaravelPayPal\Helpers;
4
5
class Environment
6
{
7
    public const SANDBOX = 'sandbox';
8
    public const LIVE = 'live';
9
    public const API_CONF = 'paypal.api';
10
11
    public static function isSandbox(): bool
12
    {
13
        return self::getCurrentEnvironment() === self::SANDBOX;
14
    }
15
16
    public static function isLive()
17
    {
18
        return self::getCurrentEnvironment() === self::LIVE;
19
    }
20
21
    public static function getClientId()
22
    {
23
        return config(self::API_CONF . '.' . self::getCurrentEnvironment() . '.credentials.client_id');
24
    }
25
26
    public static function getSecret()
27
    {
28
        return config(self::API_CONF . '.' . self::getCurrentEnvironment() . '.credentials.secret');
29
    }
30
31
    public static function getEndpoint()
32
    {
33
        return config(self::API_CONF . '.' . self::getCurrentEnvironment() . '.endpoint');
34
    }
35
36
    public static function isCheckoutActivated(): bool
37
    {
38
        return config('paypal.checkout.activated');
39
    }
40
41
    public static function areSubscriptionsActivated(): bool
42
    {
43
        return config('paypal.subscription.activated');
44
    }
45
46
    private static function getCurrentEnvironment()
47
    {
48
        return config(self::API_CONF . '.environment');
49
    }
50
}
51