Passed
Push — main ( 0d3924...d351ca )
by Iain
04:58
created

createNoBillingDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Response;
16
17
use Parthenon\Billing\Entity\Subscription;
18
use Symfony\Component\Validator\ConstraintViolationListInterface;
19
20
class StartSubscriptionResponse
21
{
22
    public const CODE_REQUEST_INVALID = '320000';
23
    public const CODE_NO_BILLING_DETAILS = '320001';
24
    public const CODE_UNSUPPORTED_PAYMENT_PROVIDER = '320002';
25
    public const CODE_PLAN_NOT_FOUND = '320003';
26
    public const CODE_PLAN_PRICE_NOT_FOUND = '320004';
27
    public const CODE_GENERAL_ERROR = '320005';
28
29
    public static function createGeneralError(): array
30
    {
31
        return [
32
            'success' => false,
33
            'code' => static::CODE_GENERAL_ERROR,
34
        ];
35
    }
36
37
    public static function createInvalidRequestResponse(ConstraintViolationListInterface $errors): array
0 ignored issues
show
Unused Code introduced by
The parameter $errors is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
    public static function createInvalidRequestResponse(/** @scrutinizer ignore-unused */ ConstraintViolationListInterface $errors): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        return [
40
            'success' => false,
41
            'code' => static::CODE_REQUEST_INVALID,
42
        ];
43
    }
44
45
    public static function createNoBillingDetails(): array
46
    {
47
        return [
48
            'success' => false,
49
            'code' => static::CODE_NO_BILLING_DETAILS,
50
        ];
51
    }
52
53
    public static function createUnsupportedPaymentProvider(): array
54
    {
55
        return [
56
            'success' => false,
57
            'code' => static::CODE_UNSUPPORTED_PAYMENT_PROVIDER,
58
        ];
59
    }
60
61
    public static function createPlanNotFound(): array
62
    {
63
        return [
64
            'success' => false,
65
            'code' => static::CODE_PLAN_NOT_FOUND,
66
        ];
67
    }
68
69
    public static function createPlanPriceNotFound(): array
70
    {
71
        return [
72
            'success' => false,
73
            'code' => static::CODE_PLAN_PRICE_NOT_FOUND,
74
        ];
75
    }
76
77
    public static function createSuccessResponse(Subscription $subscription): array
0 ignored issues
show
Unused Code introduced by
The parameter $subscription is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

77
    public static function createSuccessResponse(/** @scrutinizer ignore-unused */ Subscription $subscription): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
    {
79
        return [
80
            'success' => true,
81
        ];
82
    }
83
}
84