Conditions | 10 |
Paths | 7 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
64 | public function __construct( $name, $id, $editcount, $registration, $groups, $rights, $gender ) { |
||
65 | if ( !is_string( $name ) || empty( $name ) ) { |
||
66 | throw new InvalidArgumentException( '$name must be a string and can not be empty' ); |
||
67 | } |
||
68 | if ( !is_int( $id ) ) { |
||
69 | throw new InvalidArgumentException( '$id must be an int' ); |
||
70 | } |
||
71 | if ( !is_int( $editcount ) ) { |
||
72 | throw new InvalidArgumentException( '$editcount must be an int' ); |
||
73 | } |
||
74 | if ( !is_array( $groups ) || !array_key_exists( 'groups', $groups ) || !array_key_exists( 'implicitgroups', $groups ) ) { |
||
75 | throw new InvalidArgumentException( '$groups must be an array or arrays with keys "groups" and "implicitgroups"' ); |
||
76 | } |
||
77 | if ( !is_array( $rights ) ) { |
||
78 | throw new InvalidArgumentException( '$rights must be an array' ); |
||
79 | } |
||
80 | if ( !is_string( $gender ) ) { |
||
81 | throw new InvalidArgumentException( '$gender must be a string' ); |
||
82 | } |
||
83 | |||
84 | $this->editcount = $editcount; |
||
85 | $this->gender = $gender; |
||
86 | $this->groups = $groups; |
||
87 | $this->id = $id; |
||
88 | $this->name = $name; |
||
89 | $this->registration = $registration; |
||
90 | $this->rights = $rights; |
||
91 | } |
||
92 | |||
145 |