Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 1 |
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 |
||
15 | public function init() |
||
16 | { |
||
17 | // $this->db->setVerbose(); |
||
18 | $this->db->dropTableIfExists('commentsindb')->execute(); |
||
|
|||
19 | |||
20 | $this->db->createTable( |
||
21 | 'commentsindb', |
||
22 | [ |
||
23 | 'id' => ['integer', 'primary key', 'not null', 'auto_increment'], |
||
24 | 'flow' => ['varchar(80)'], |
||
25 | 'name' => ['varchar(80)'], |
||
26 | 'mail' => ['varchar(80)'], |
||
27 | 'web' => ['varchar(80)'], |
||
28 | 'content' => ['varchar(1024)'], |
||
29 | 'created' => ['datetime'], |
||
30 | ] |
||
31 | )->execute(); |
||
32 | $this->db->insert( |
||
33 | 'commentsindb', |
||
34 | ['flow', 'name', 'mail', 'web', 'content', 'created'] |
||
35 | ); |
||
36 | |||
37 | $now = time(); |
||
38 | |||
39 | $this->db->execute([ |
||
40 | 'commentadmin/lorem', |
||
41 | 'Fredrik Nilsson', |
||
42 | '[email protected]', |
||
43 | 'www.dbwebb.se', |
||
44 | 'Lorem ipsum dolor sit amet, ad nam graeci dissentias, te verear utroque per. Doming intellegat mea id, mel ei dicta iudico. Dicunt fabulas usu ad. Per nemore possim commune ut, eu probo dicta has. ', |
||
45 | $now |
||
46 | ]); |
||
47 | |||
48 | $this->db->execute([ |
||
49 | 'commentadmin/lorem', |
||
50 | 'Joe Doe', |
||
51 | '[email protected]', |
||
52 | 'test.dbwebb.se', |
||
53 | 'Accusam eleifend qui ex. Has duis iuvaret salutatus id, dico illud porro ea mei, id oblique tibique eos. Ne eam meis equidem admodum, eos nisl maluisset id. Ancillae lucilius persecuti no sed.', |
||
54 | $now |
||
55 | ]); |
||
56 | |||
57 | $this->db->execute([ |
||
58 | 'calendar', |
||
59 | 'Jane Doe', |
||
60 | '[email protected]', |
||
61 | 'jane.dbwebb.se', |
||
62 | 'Sea te vocibus dolores pertinax, quodsi insolens appellantur sit an, dicam definitionem sed ne.', |
||
63 | $now |
||
64 | ]); |
||
65 | |||
66 | } |
||
67 | View Code Duplication | private function humanTiming($time) |
|
153 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read 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.