These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Srmklive\PayPal\Traits; |
||
4 | |||
5 | use Carbon\Carbon; |
||
6 | |||
7 | trait RecurringProfiles |
||
8 | { |
||
9 | /** |
||
10 | * Create recurring subscription on monthly basis. |
||
11 | * |
||
12 | * @param string $token |
||
13 | * @param float $amount |
||
14 | * @param string $description |
||
15 | * |
||
16 | * @return array |
||
17 | */ |
||
18 | View Code Duplication | public function createMonthlySubscription($token, $amount, $description) |
|
0 ignored issues
–
show
|
|||
19 | { |
||
20 | $data = [ |
||
21 | 'PROFILESTARTDATE' => Carbon::now()->toAtomString(), |
||
22 | 'DESC' => $description, |
||
23 | 'BILLINGPERIOD' => 'Month', |
||
24 | 'BILLINGFREQUENCY' => 1, |
||
25 | 'AMT' => $amount, |
||
26 | 'CURRENCYCODE' => $this->currency, |
||
0 ignored issues
–
show
The property
currency does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
27 | ]; |
||
28 | |||
29 | return $this->createRecurringPaymentsProfile($data, $token); |
||
0 ignored issues
–
show
It seems like
createRecurringPaymentsProfile() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the
Loading history...
|
|||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Create recurring subscription on yearly basis. |
||
34 | * |
||
35 | * @param string $token |
||
36 | * @param float $amount |
||
37 | * @param string $description |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | View Code Duplication | public function createYearlySubscription($token, $amount, $description) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
42 | { |
||
43 | $data = [ |
||
44 | 'PROFILESTARTDATE' => Carbon::now()->toAtomString(), |
||
45 | 'DESC' => $description, |
||
46 | 'BILLINGPERIOD' => 'Year', |
||
47 | 'BILLINGFREQUENCY' => 1, |
||
48 | 'AMT' => $amount, |
||
49 | 'CURRENCYCODE' => $this->currency, |
||
50 | ]; |
||
51 | |||
52 | return $this->createRecurringPaymentsProfile($data, $token); |
||
0 ignored issues
–
show
It seems like
createRecurringPaymentsProfile() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the
Loading history...
|
|||
53 | } |
||
54 | } |
||
55 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.