Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 2 |
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 |
||
16 | public function init() |
||
17 | { |
||
18 | $this->db->setVerbose(); |
||
|
|||
19 | $this->db->dropTableIfExists('cquestions')->execute(); |
||
20 | |||
21 | $this->db->createTable( |
||
22 | 'cquestions', |
||
23 | [ |
||
24 | 'id' => ['integer', 'primary key', 'not null', 'auto_increment'], |
||
25 | 'headline' => ['varchar(80)'], |
||
26 | 'content' => ['varchar(1024)'], |
||
27 | 'user_id' => ['int'], |
||
28 | 'vote' => ['int'], |
||
29 | 'accepted_answer' => ['bool', 'DEFAULT', '0'], |
||
30 | 'created' => ['datetime'], |
||
31 | ] |
||
32 | )->execute(); |
||
33 | $this->db->insert( |
||
34 | 'cquestions', |
||
35 | ['headline', 'content', 'user_id', 'vote', 'created'] |
||
36 | ); |
||
37 | |||
38 | $now = time(); |
||
39 | |||
40 | $this->db->execute([ |
||
41 | 'Fråga 1?', |
||
42 | 'Lorem ipsum dolor sit amet, [consectetur](https://daringfireball.net/projects/markdown/syntax#link) adipiscing elit. Praesent non urna at lectus venenatis facilisis. Nullam rutrum tortor at aliquet tincidunt. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut ullamcorper purus. Sed elementum purus quis tortor finibus, eget vestibulum lorem finibus. Vestibulum porta ligula in risus aliquam luctus. Ut eget sapien libero.', |
||
43 | 1, |
||
44 | 0, |
||
45 | $now |
||
46 | ]); |
||
47 | |||
48 | $this->db->execute([ |
||
49 | 'Fråga 2?', |
||
50 | 'Suspendisse eget rutrum mauris. Morbi dictum vulputate pulvinar. Sed feugiat lobortis arcu, ut feugiat mauris sagittis a. Nulla leo ante, interdum id accumsan sit amet, tempor nec urna. ', |
||
51 | 1, |
||
52 | 0, |
||
53 | $now |
||
54 | ]); |
||
55 | $this->db->execute([ |
||
56 | 'Fråga 3?', |
||
57 | 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut ullamcorper purus. Sed elementum purus quis tortor finibus, eget vestibulum lorem finibus. Vestibulum porta ligula in risus aliquam luctus. Ut eget sapien libero.', |
||
58 | 2, |
||
59 | 0, |
||
60 | $now |
||
61 | ]); |
||
62 | $this->db->execute([ |
||
63 | 'Fråga 4?', |
||
64 | 'Suspendisse eget rutrum mauris. Morbi dictum vulputate pulvinar. Sed feugiat lobortis arcu, ut feugiat mauris sagittis a. Nulla leo ante, interdum id accumsan sit amet, tempor nec urna. ', |
||
65 | 3, |
||
66 | 0, |
||
67 | $now |
||
68 | ]); |
||
69 | $this->db->execute([ |
||
70 | 'Fråga 5?', |
||
71 | 'Suspendisse eget rutrum mauris. Morbi dictum vulputate pulvinar. Sed feugiat lobortis arcu, ut feugiat mauris sagittis a. Nulla leo ante, interdum id accumsan sit amet, tempor nec urna. ', |
||
72 | 3, |
||
73 | 0, |
||
74 | $now |
||
75 | ]); |
||
76 | $this->db->execute([ |
||
77 | 'Fråga 6?', |
||
78 | 'Suspendisse eget rutrum mauris. Morbi dictum vulputate pulvinar. Sed feugiat lobortis arcu, ut feugiat mauris sagittis a. Nulla leo ante, interdum id accumsan sit amet, tempor nec urna. ', |
||
79 | 1, |
||
80 | 0, |
||
81 | $now |
||
82 | ]); |
||
83 | } |
||
84 | /** |
||
119 |
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.