Passed
Branch master (b53e94)
by Justin
05:11
created

Subscription::resume()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "Subscription.php" doesn't match the expected filename "subscription.php"
Loading history...
introduced by
The PHP open tag must be followed by exactly one blank line
Loading history...
2
/**
0 ignored issues
show
introduced by
Namespaced classes, interfaces and traits should not begin with a file doc comment
Loading history...
3
 * This file implements a Subscription.
4
 *
5
 * @author    Bilal Gultekin <[email protected]>
0 ignored issues
show
Coding Style introduced by
Expected "Squiz Pty Ltd <[email protected]>" for author tag
Loading history...
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
introduced by
Tag value indented incorrectly; expected 1 space but found 4
Loading history...
6
 * @author    Justin Hartman <[email protected]>
0 ignored issues
show
Coding Style introduced by
Only one @author tag is allowed in a file comment
Loading history...
Coding Style introduced by
Expected "Squiz Pty Ltd <[email protected]>" for author tag
Loading history...
Coding Style introduced by
The tag in position 2 should be the @subpackage tag
Loading history...
introduced by
Tag value indented incorrectly; expected 1 space but found 4
Loading history...
7
 * @copyright 2019 22 Digital
0 ignored issues
show
Coding Style Documentation introduced by
Expected "xxxx-xxxx Squiz Pty Ltd (ABN 77 084 670 600)" for copyright declaration
Loading history...
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
8
 * @license   MIT
0 ignored issues
show
Coding Style introduced by
The tag in position 4 should be the @copyright tag
Loading history...
Coding Style introduced by
@license tag must contain a URL and a license name
Loading history...
introduced by
Tag value indented incorrectly; expected 1 space but found 3
Loading history...
9
 * @since     v0.1
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 5
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style Documentation introduced by
Missing @package tag in file comment
Loading history...
Coding Style Documentation introduced by
Missing @subpackage tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace TwentyTwoDigital\CashierFastspring;
13
14
use Carbon\Carbon;
15
use Exception;
16
use Illuminate\Database\Eloquent\Model;
17
use LogicException;
18
use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;
19
20
/**
21
 * This class describes a subscription.
22
 *
23
 * {@inheritdoc}
24
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
25
class Subscription extends Model
26
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Subscription
Loading history...
introduced by
Opening brace should be on the same line as the declaration
Loading history...
27
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
28
     * The attributes that are not mass assignable.
29
     *
30
     * @var array
31
     */
32
    protected $guarded = [];
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
Coding Style introduced by
Protected member variable "guarded" must contain a leading underscore
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
35
     * The attributes that should be mutated to dates.
36
     *
37
     * @var array
38
     */
39
    protected $dates = [
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Protected member variable "dates" must contain a leading underscore
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
40
        'created_at', 'updated_at', 'swap_at',
0 ignored issues
show
introduced by
Array indentation error, expected 6 spaces but found 8
Loading history...
41
    ];
42
43
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
44
     * The date on which the billing cycle should be anchored.
45
     *
46
     * @var string|null
47
     */
48
    protected $billingCycleAnchor = null;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Protected member variable "billingCycleAnchor" must contain a leading underscore
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
49
50
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
51
     * Get the user that owns the subscription.
52
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
53 1
    public function user()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
54
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
55 1
        return $this->owner();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
56
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end user()
Loading history...
57
58
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
59
     * Get periods of the subscription.
60
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
61 11
    public function periods()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
62
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
63 11
        return $this->hasMany('TwentyTwoDigital\CashierFastspring\SubscriptionPeriod');
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
64
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end periods()
Loading history...
65
66
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
67
     * Get active period of the subscription.
68
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
69 6
    public function activePeriod()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
70
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
71 6
        return $this->hasOne('TwentyTwoDigital\CashierFastspring\SubscriptionPeriod')
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
72 6
                    ->where('start_date', '<=', Carbon::now()->format('Y-m-d H:i:s'))
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 20
Loading history...
73 6
                    ->where('end_date', '>=', Carbon::now()->format('Y-m-d H:i:s'))
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
Coding Style introduced by
Space found before object operator
Loading history...
74 6
                    ->where('type', $this->type());
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 12 spaces but found 20
Loading history...
Coding Style introduced by
Space found before object operator
Loading history...
75
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end activePeriod()
Loading history...
76
77
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
78
     * Get active period or retrieve the active period from fastspring and create.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 82 characters
Loading history...
79
     *
80
     * Note: This is not eloquent relation, it returns SubscriptionPeriod model directly.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 89 characters
Loading history...
81
     *
82
     * @return \TwentyTwoDigital\CashierFastspring\SubscriptionPeriod
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
83
     */
84 10
    public function activePeriodOrCreate()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
85
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
86 10
        if ($this->isFastspring()) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
87 5
            return $this->activeFastspringPeriodOrCreate();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
88
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
89
90 5
        return $this->activeLocalPeriodOrCreate();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
91
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end activePeriodOrCreate()
Loading history...
92
93
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
94
     * Get active fastspring period or retrieve the active period from fastspring and create.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 93 characters
Loading history...
95
     *
96
     * @return \TwentyTwoDigital\CashierFastspring\SubscriptionPeriod
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
97
     */
98 5
    public function activeFastspringPeriodOrCreate()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
99
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
100
        // activePeriod is not used on purpose
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
101
        // because it caches and causes confusion
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
102
        // after this method is called
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
103 5
        $today = Carbon::today()->format('Y-m-d');
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
104
105 5
        $activePeriod = SubscriptionPeriod::where('subscription_id', $this->id)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
106 5
            ->where('start_date', '<=', $today)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 12
Loading history...
107 5
            ->where('end_date', '>=', $today)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
108 5
            ->where('type', 'fastspring')
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
109 5
            ->first();
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
110
111
        // if there is any return it
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
112 5
        if ($activePeriod) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
113 2
            return $activePeriod;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
114
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
115
116 4
        return $this->createPeriodFromFastspring();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
117
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end activeFastspringPeriodOrCreate()
Loading history...
118
119
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
120
     * Get active local period or create.
121
     *
122
     * @return \TwentyTwoDigital\CashierFastspring\SubscriptionPeriod
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
123
     */
124 5
    public function activeLocalPeriodOrCreate()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
125
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
126
        // activePeriod is not used on purpose
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
127
        // because it caches and causes confusion
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
128
        // after this method is called
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
129 5
        $today = Carbon::today()->format('Y-m-d');
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
130
131 5
        $activePeriod = SubscriptionPeriod::where('subscription_id', $this->id)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
132 5
            ->where('start_date', '<=', $today)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 12
Loading history...
133 5
            ->where('end_date', '>=', $today)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
134 5
            ->where('type', 'local')
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
135 5
            ->first();
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
136
137
        // if there is any return it
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
138 5
        if ($activePeriod) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
139
            return $activePeriod;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
140
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
141
142 5
        return $this->createPeriodLocally();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
143
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end activeLocalPeriodOrCreate()
Loading history...
144
145
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
146
     * Create period with the information from fastspring.
147
     *
148
     * @return \TwentyTwoDigital\CashierFastspring\SubscriptionPeriod
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
149
     */
150 4
    protected function createPeriodFromFastspring()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
151
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
152 4
        $response = Fastspring::getSubscriptionsEntries([$this->fastspring_id]);
0 ignored issues
show
Bug introduced by
The method getSubscriptionsEntries() does not exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

152
        /** @scrutinizer ignore-call */ 
153
        $response = Fastspring::getSubscriptionsEntries([$this->fastspring_id]);
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
153
154
        $period = [
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
155
            // there is no info related to type in the entries endpoint
0 ignored issues
show
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
156
            // so we assume it is regular type
157
            // because we create first periods (especially including trial if there is any)
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 91 characters
Loading history...
158
            // at the subscription creation
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
159 4
            'type' => 'fastspring',
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
160
161
            // dates
0 ignored issues
show
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
162 4
            'start_date'      => $response[0]->beginPeriodDate,
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
163 4
            'end_date'        => $response[0]->endPeriodDate,
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
164 4
            'subscription_id' => $this->id,
0 ignored issues
show
introduced by
Array indentation error, expected 10 spaces but found 12
Loading history...
165
        ];
166
167
        // try to find or create
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
168 4
        return SubscriptionPeriod::firstOrCreate($period);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
169
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end createPeriodFromFastspring()
Loading history...
170
171
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
172
     * Create period for non-fastspring/local subscriptions.
173
     *
174
     * Simply finds latest and add its dates $interval_length * $interval_unit
175
     * If there is no subscription period, it creates a subscription period started today
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 89 characters
Loading history...
introduced by
Doc comment long description must end with a full stop
Loading history...
176
     *
177
     * @throws \Exception
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
178
     *
179
     * @return \TwentyTwoDigital\CashierFastspring\SubscriptionPeriod
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
180
     */
181 5
    protected function createPeriodLocally()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
182
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
183 5
        $lastPeriod = $this->periods()->orderBy('end_date', 'desc')->first();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
184 5
        $today = Carbon::today();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
185
186
        // there may be times subscriptionperiods not created more than
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
187
        // interval_length * interval_unit
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
188
        // For this kind of situations, we should fill the blank (actually we dont
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 82 characters
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
189
        // have to but while we are calculating it is nice to save them)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
190
        do {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
191
            // add interval value to it to create next start_date
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
192
            // and sub one day to get next end_date
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
193 5
            switch ($this->interval_unit) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Variable "interval_unit" is not in valid camel caps format
Loading history...
194
                // fastspring adds month without overflow
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
195
                // so lets we do the same
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
196 5
                case 'month':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
197 2
                    $start_date = $lastPeriod
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
198 1
                        ? $lastPeriod->start_date->addMonthsNoOverflow($this->interval_length)
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
199 2
                        : Carbon::now();
0 ignored issues
show
Coding Style introduced by
Expected 1 space before ":"; newline found
Loading history...
200
201 2
                    $end_date = $start_date->copy()->addMonthsNoOverflow($this->interval_length)->subDay();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
202 2
                    break;
0 ignored issues
show
introduced by
Case breaking statement indented incorrectly; expected 18 spaces, found 20
Loading history...
203
204 3
                case 'week':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
205 1
                    $start_date = $lastPeriod
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
206 1
                        ? $lastPeriod->start_date->addWeeks($this->interval_length)
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
207 1
                        : Carbon::now();
0 ignored issues
show
Coding Style introduced by
Expected 1 space before ":"; newline found
Loading history...
208
209 1
                    $end_date = $start_date->copy()->addWeeks($this->interval_length)->subDay();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
210 1
                    break;
0 ignored issues
show
introduced by
Case breaking statement indented incorrectly; expected 18 spaces, found 20
Loading history...
211
212
                // probably same thing with the year
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
213 2
                case 'year':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
214 1
                    $start_date = $lastPeriod
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
215 1
                        ? $lastPeriod->start_date->addYearsNoOverflow($this->interval_length)
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
216 1
                        : Carbon::now();
0 ignored issues
show
Coding Style introduced by
Expected 1 space before ":"; newline found
Loading history...
217
218 1
                    $end_date = $start_date->copy()->addYearsNoOverflow($this->interval_length)->subDay();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "interval_length" is not in valid camel caps format
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 106 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
219 1
                    break;
0 ignored issues
show
introduced by
Case breaking statement indented incorrectly; expected 18 spaces, found 20
Loading history...
220
221
                default:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
222 1
                    throw new Exception('Unexcepted interval unit: ' . $subscription->interval_unit);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $subscription does not exist. Did you maybe mean $subscriptionPeriodData?
Loading history...
introduced by
Case breaking statement indented incorrectly; expected 18 spaces, found 20
Loading history...
Coding Style introduced by
Variable "interval_unit" is not in valid camel caps format
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
223
            }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
End comment for long condition not found; expected "//end switch"
Loading history...
224
225
            $subscriptionPeriodData = [
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
226 4
                'type'            => 'local',
0 ignored issues
show
introduced by
Array indentation error, expected 14 spaces but found 16
Loading history...
227 4
                'start_date'      => $start_date->format('Y-m-d'),
0 ignored issues
show
introduced by
Array indentation error, expected 14 spaces but found 16
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
228 4
                'end_date'        => $end_date->format('Y-m-d'),
0 ignored issues
show
introduced by
Array indentation error, expected 14 spaces but found 16
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
229 4
                'subscription_id' => $this->id,
0 ignored issues
show
introduced by
Array indentation error, expected 14 spaces but found 16
Loading history...
230
            ];
231
232 4
            $lastPeriod = SubscriptionPeriod::firstOrCreate($subscriptionPeriodData);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
233 4
        } while (!($today->greaterThanOrEqualTo($lastPeriod->start_date)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
Coding Style introduced by
Variable "start_date" is not in valid camel caps format
Loading history...
234 4
            && $today->lessThanOrEqualTo($lastPeriod->end_date)
0 ignored issues
show
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
235
        ));
236
237 4
        return $lastPeriod;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
238
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end createPeriodLocally()
Loading history...
239
240
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
241
     * Get the model related to the subscription.
242
     *
243
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
244
     */
245 1
    public function owner()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
246
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
247 1
        $model = getenv('FASTSPRING_MODEL') ?: config('services.fastspring.model', 'App\\User');
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
248
249 1
        $model = new $model();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
250
251 1
        return $this->belongsTo(get_class($model), $model->getForeignKey());
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
252
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end owner()
Loading history...
253
254
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
255
     * Determine if the subscription is valid.
256
     * This includes following states on fastspring: active, trial, overdue, canceled.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 86 characters
Loading history...
257
     * The only state that you should stop serving is deactivated state.
0 ignored issues
show
introduced by
Doc comment short description must be on a single line, further text should be a separate paragraph
Loading history...
258
     *
259
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
260
     */
261 5
    public function valid()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
262
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
263 5
        return !$this->deactivated();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
264
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end valid()
Loading history...
265
266
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
267
     * Determine if the subscription is active.
268
     *
269
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
270
     */
271 4
    public function active()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
272
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
273 4
        return $this->state == 'active';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
274
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end active()
Loading history...
275
276
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
277
     * Determine if the subscription is deactivated.
278
     *
279
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
280
     */
281 5
    public function deactivated()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
282
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
283 5
        return $this->state == 'deactivated';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
284
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end deactivated()
Loading history...
285
286
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
287
     * Determine if the subscription is not paid and in wait.
288
     *
289
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
290
     */
291 4
    public function overdue()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
292
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
293 4
        return $this->state == 'overdue';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
294
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end overdue()
Loading history...
295
296
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
297
     * Determine if the subscription is on trial.
298
     *
299
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
300
     */
301 5
    public function trial()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
302
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
303 5
        return $this->state == 'trial';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
304
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end trial()
Loading history...
305
306
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
307
     * Determine if the subscription is cancelled.
308
     *
309
     * Note: That doesn't mean you should stop serving. This state means
310
     * user ordered to cancel at end of the billing period.
311
     * Subscription is converted into deactivated on the start of next payment period,
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 86 characters
Loading history...
312
     * after cancelling it.
313
     *
314
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
315
     */
316 7
    public function canceled()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
317
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
318 7
        return $this->state == 'canceled';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
319
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end canceled()
Loading history...
320
321
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
322
     * ALIASES.
323
     */
324
325
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
326
     * Alias of canceled.
327
     *
328
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
329
     */
330 2
    public function cancelled()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
331
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
332 2
        return $this->canceled();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
333
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end cancelled()
Loading history...
334
335
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
336
     * Determine if the subscription is within its trial period.
337
     *
338
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
339
     */
340 5
    public function onTrial()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
341
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
342 5
        return $this->trial();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
343
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end onTrial()
Loading history...
344
345
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
346
     * Determine if the subscription is within its grace period after cancellation.
0 ignored issues
show
introduced by
Line exceeds 80 characters; contains 83 characters
Loading history...
347
     *
348
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
349
     */
350 7
    public function onGracePeriod()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
351
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
352 7
        return $this->canceled();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
353
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end onGracePeriod()
Loading history...
354
355
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
356
     * Determine type of the subscription: fastspring, local.
357
     *
358
     * @return string
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
359
     */
360 11
    public function type()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
361
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
362 11
        return $this->fastspring_id ? 'fastspring' : 'local';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement requires brackets around comparison
Loading history...
363
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end type()
Loading history...
364
365
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
366
     * Determine if the subscription is local.
367
     *
368
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
introduced by
Description for the @return value is missing
Loading history...
369
     */
370 1
    public function isLocal()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
371
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
372 1
        return $this->type() == 'local';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
373
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isLocal()
Loading history...
374
375
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
376
     * Determine if the subscription is fastspring.
377
     *
378
     * @return string
0 ignored issues
show
introduced by
Description for the @return value is missing
Loading history...
379
     */
380 11
    public function isFastspring()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
381
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
382 11
        return $this->type() == 'fastspring';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
383
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isFastspring()
Loading history...
384
385
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
386
     * Swap the subscription to a new Fastspring plan.
387
     *
388
     * @param string $plan     New plan
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
389
     * @param bool   $prorate  Prorate
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
introduced by
Expected 1 spaces after parameter type; 3 found
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
390
     * @param int    $quantity Quantity of the product
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
introduced by
Expected 1 spaces after parameter type; 4 found
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
391
     * @param array  $coupons  Coupons wanted to be applied
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
introduced by
Parameter comment must be on the next line
Loading history...
392
     *
393
     * @throws \Exception
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
394
     *
395
     * @return object Response of fastspring
0 ignored issues
show
introduced by
Description for the @return value must be on the next line
Loading history...
396
     */
397 2
    public function swap($plan, $prorate, $quantity = 1, $coupons = [])
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Type hint "string" missing for $plan
Loading history...
Coding Style introduced by
Type hint "bool" missing for $prorate
Loading history...
Coding Style introduced by
Type hint "int" missing for $quantity
Loading history...
introduced by
Type hint "array" missing for $coupons
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
398
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
399 2
        $response = Fastspring::swapSubscription($this->fastspring_id, $plan, $prorate, $quantity, $coupons);
0 ignored issues
show
Bug introduced by
The method swapSubscription() does not exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

399
        /** @scrutinizer ignore-call */ 
400
        $response = Fastspring::swapSubscription($this->fastspring_id, $plan, $prorate, $quantity, $coupons);
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 109 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
400 2
        $status = $response->subscriptions[0];
0 ignored issues
show
Bug introduced by
The property subscriptions does not seem to exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
401
402 2
        if ($status->result == 'success') {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Operator == prohibited; use === instead
Loading history...
403
            // we update subscription
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
404
            // according to prorate value
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
405 2
            if ($prorate) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
406
                // if prorate is true
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
407
                // the plan is changed immediately
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
408
                // no need to fill swap columns
0 ignored issues
show
introduced by
There must be no blank line following an inline comment
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
409
410
                // if the plan is in the trial state
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
411
                // then delete the current period
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
412
                // because it will change immediately
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
413
                // but period won't update because it exists
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
414 1
                if ($this->state == 'trial') {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Operator == prohibited; use === instead
Loading history...
415
                    $activePeriod = $this->activePeriodOrCreate();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
416
                    $activePeriod->delete();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 10 spaces, found 20
Loading history...
417
                }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
418
419 1
                $this->plan = $plan;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
420 1
                $this->save();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
421
            } else {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
introduced by
Expected newline after closing brace
Loading history...
422
                // if prorate is false
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
423
                // save plan swap_to
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
424
                // because the plan will change after a while
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
425 1
                $activePeriod = $this->activePeriodOrCreate();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
426
427 1
                $this->swap_to = $plan;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Variable "swap_to" is not in valid camel caps format
Loading history...
428 1
                $this->swap_at = $activePeriod
0 ignored issues
show
introduced by
$activePeriod is of type TwentyTwoDigital\Cashier...ring\SubscriptionPeriod, thus it always evaluated to true.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
Coding Style introduced by
Variable "swap_at" is not in valid camel caps format
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
429 1
                    ? $activePeriod->end_date
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
430
                    : null;
0 ignored issues
show
Coding Style introduced by
Expected 1 space before ":"; newline found
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
431 1
                $this->save();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 16
Loading history...
432
            }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
End comment for long condition not found; expected "//end if"
Loading history...
433
434 2
            return $this;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
435
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
End comment for long condition not found; expected "//end if"
Loading history...
436
437
        throw new Exception('Swap operation failed. Response: ' . json_encode($response));
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
438
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end swap()
Loading history...
439
440
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
441
     * Cancel the subscription at the end of the billing period.
442
     *
443
     * @throws \Exception
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
444
     *
445
     * @return object Response of fastspring
0 ignored issues
show
introduced by
Description for the @return value must be on the next line
Loading history...
446
     */
447 2
    public function cancel()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
448
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
449 2
        $response = Fastspring::cancelSubscription($this->fastspring_id);
0 ignored issues
show
Bug introduced by
The method cancelSubscription() does not exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

449
        /** @scrutinizer ignore-call */ 
450
        $response = Fastspring::cancelSubscription($this->fastspring_id);
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
450 2
        $status = $response->subscriptions[0];
0 ignored issues
show
Bug introduced by
The property subscriptions does not seem to exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
451 2
        $activePeriod = $this->activePeriodOrCreate();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
452
453 2
        if ($status->result == 'success') {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Operator == prohibited; use === instead
Loading history...
454 1
            $this->state = 'canceled';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
455 1
            $this->swap_at = $activePeriod
0 ignored issues
show
introduced by
$activePeriod is of type TwentyTwoDigital\Cashier...ring\SubscriptionPeriod, thus it always evaluated to true.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Variable "swap_at" is not in valid camel caps format
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
456 1
                ? $activePeriod->end_date
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "?"; newline found
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Variable "end_date" is not in valid camel caps format
Loading history...
457
                : null;
0 ignored issues
show
Coding Style introduced by
Expected 1 space before ":"; newline found
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
458 1
            $this->save();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
459
460 1
            return $this;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
461
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
462
463 1
        throw new Exception('Cancel operation failed. Response: ' . json_encode($response));
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
464
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end cancel()
Loading history...
465
466
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
467
     * Cancel the subscription immediately.
468
     *
469
     * @throws \Exception
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
470
     *
471
     * @return object Response of fastspring
0 ignored issues
show
introduced by
Description for the @return value must be on the next line
Loading history...
472
     */
473 2
    public function cancelNow()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
474
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
475 2
        $response = Fastspring::cancelSubscription($this->fastspring_id, ['billing_period' => 0]);
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
476 2
        $status = $response->subscriptions[0];
0 ignored issues
show
Bug introduced by
The property subscriptions does not seem to exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
477
478 2
        if ($status->result == 'success') {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Operator == prohibited; use === instead
Loading history...
479
            // if it is canceled now
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
480
            // state should be deactivated
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
481 1
            $this->state = 'deactivated';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
482 1
            $this->save();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
483
484 1
            return $this;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
485
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
486
487 1
        throw new Exception('CancelNow operation failed. Response: ' . json_encode($response));
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
488
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end cancelNow()
Loading history...
489
490
    /**
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
491
     * Resume the cancelled subscription.
492
     *
493
     * @throws \LogicException
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
494
     * @throws \Exception
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
495
     *
496
     * @return object Response of fastspring
0 ignored issues
show
introduced by
Description for the @return value must be on the next line
Loading history...
497
     */
498 3
    public function resume()
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
499
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
500 3
        if (!$this->onGracePeriod()) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
501 1
            throw new LogicException('Unable to resume subscription that is not within grace period or not canceled.');
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 119 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
502
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
503
504 2
        $response = Fastspring::uncancelSubscription($this->fastspring_id);
0 ignored issues
show
Bug introduced by
The method uncancelSubscription() does not exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

504
        /** @scrutinizer ignore-call */ 
505
        $response = Fastspring::uncancelSubscription($this->fastspring_id);
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Variable "fastspring_id" is not in valid camel caps format
Loading history...
505 2
        $status = $response->subscriptions[0];
0 ignored issues
show
Bug introduced by
The property subscriptions does not seem to exist on TwentyTwoDigital\Cashier...g\Fastspring\Fastspring.
Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
506
507 2
        if ($status->result == 'success') {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
Coding Style introduced by
Operator == prohibited; use === instead
Loading history...
508 1
            $this->state = 'active';
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
509
510
            // set null swap columns
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
introduced by
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
511 1
            $this->swap_at = null;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Variable "swap_at" is not in valid camel caps format
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
512 1
            $this->swap_to = null;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
Coding Style introduced by
Variable "swap_to" is not in valid camel caps format
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
513
514 1
            $this->save();
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
515
516 1
            return $this;
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 6 spaces, found 12
Loading history...
517
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
518
519 1
        throw new Exception('Resume operation failed. Response: ' . json_encode($response));
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
520
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 2 spaces, found 4
Loading history...
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end resume()
Loading history...
521
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
522