Environment::getCurrentEnvironment()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Pleets\LaravelPayPal\Helpers;
4
5
class Environment
6
{
7
    public const SANDBOX = 'sandbox';
8
    public const LIVE = 'live';
9
    private 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(): bool
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 isHandlerEnabled(): bool
37
    {
38
        return config('paypal.testing.handler.enabled');
39
    }
40
41
    public static function getHandler()
42
    {
43
        return config('paypal.testing.handler.class');
44
    }
45
46
    public static function isCheckoutActivated(): bool
47
    {
48
        return config('paypal.checkout.activated');
49
    }
50
51
    public static function areSubscriptionsActivated(): bool
52
    {
53
        return config('paypal.subscription.activated');
54
    }
55
56
    private static function getCurrentEnvironment()
57
    {
58
        return config(self::API_CONF . '.environment');
59
    }
60
}
61