Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
15 | class StripeConnect |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * |
||
20 | */ |
||
21 | private static function prepare() |
||
25 | |||
26 | /** |
||
27 | * @param $user |
||
28 | * @return Stripe |
||
29 | */ |
||
30 | private static function getStripeModel($user) |
||
40 | |||
41 | /** |
||
42 | * @param $to |
||
43 | * @param array $params |
||
44 | * @return Stripe |
||
45 | */ |
||
46 | View Code Duplication | public static function createAccount($to, $params = []) |
|
56 | |||
57 | /** |
||
58 | * @param $token |
||
59 | * @param $from |
||
60 | * @param array $params |
||
61 | * @return Stripe |
||
62 | */ |
||
63 | View Code Duplication | public static function createCustomer($token, $from, $params = []) |
|
73 | |||
74 | /** |
||
75 | * @param $user |
||
76 | * @param $id_key |
||
77 | * @param $callback |
||
78 | * @return Stripe |
||
79 | */ |
||
80 | private static function create($user, $id_key, $callback) { |
||
89 | |||
90 | /** |
||
91 | * @param null $token |
||
92 | * @return Transaction |
||
93 | */ |
||
94 | public static function transaction($token = null) |
||
98 | } |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.