Conditions | 1 |
Paths | 1 |
Total Lines | 98 |
Code Lines | 74 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 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 |
||
43 | public function testParseCompleteConfig() |
||
44 | { |
||
45 | $oldConfig = [ |
||
46 | 'mail_adapter' => 'Zend\Mail\Transport\Smtp', |
||
47 | |||
48 | 'from' => '[email protected]', |
||
49 | 'from_name' => 'Alejandro', |
||
50 | 'to' => [], |
||
51 | 'cc' => [], |
||
52 | 'bcc' => [], |
||
53 | 'subject' => 'The subject', |
||
54 | 'body' => 'The body', |
||
55 | 'body_charset' => 'utf-8', |
||
56 | 'template' => [ |
||
57 | 'use_template' => false, |
||
58 | 'path' => 'ac-mailer/mail-templates/layout', |
||
59 | 'params' => [], |
||
60 | 'children' => [ |
||
61 | 'content' => [ |
||
62 | 'path' => 'ac-mailer/mail-templates/mail', |
||
63 | 'params' => [], |
||
64 | ] |
||
65 | ] |
||
66 | ], |
||
67 | 'attachments' => [ |
||
68 | 'files' => [], |
||
69 | 'dir' => [ |
||
70 | 'iterate' => false, |
||
71 | 'path' => 'data/mail/attachments', |
||
72 | 'recursive' => false, |
||
73 | ], |
||
74 | ], |
||
75 | |||
76 | 'server' => 'localhost', |
||
77 | 'smtp_user' => 'me', |
||
78 | 'smtp_password' => 'foobar', |
||
79 | 'ssl' => false, |
||
80 | 'connection_class' => 'login', |
||
81 | 'port' => 25, |
||
82 | |||
83 | 'file_path' => 'data/mail/output', |
||
84 | 'file_callback' => [], |
||
85 | ]; |
||
86 | $expected = [ |
||
87 | 'acmailer_options' => [ |
||
88 | 'default' => [ |
||
89 | 'mail_adapter' => 'Zend\Mail\Transport\Smtp', |
||
90 | 'message_options' => [ |
||
91 | 'from' => '[email protected]', |
||
92 | 'from_name' => 'Alejandro', |
||
93 | 'to' => [], |
||
94 | 'cc' => [], |
||
95 | 'bcc' => [], |
||
96 | 'subject' => 'The subject', |
||
97 | 'body' => [ |
||
98 | 'content' => 'The body', |
||
99 | 'charset' => 'utf-8', |
||
100 | 'use_template' => false, |
||
101 | 'template' => [ |
||
102 | 'path' => 'ac-mailer/mail-templates/layout', |
||
103 | 'params' => [], |
||
104 | 'children' => [ |
||
105 | 'content' => [ |
||
106 | 'path' => 'ac-mailer/mail-templates/mail', |
||
107 | 'params' => [], |
||
108 | ] |
||
109 | ], |
||
110 | 'default_layout' => [] |
||
111 | ], |
||
112 | ], |
||
113 | 'attachments' => [ |
||
114 | 'files' => [], |
||
115 | 'dir' => [ |
||
116 | 'iterate' => false, |
||
117 | 'path' => 'data/mail/attachments', |
||
118 | 'recursive' => false, |
||
119 | ], |
||
120 | ], |
||
121 | ], |
||
122 | 'smtp_options' => [ |
||
123 | 'host' => 'localhost', |
||
124 | 'port' => 25, |
||
125 | 'connection_class' => 'login', |
||
126 | 'connection_config' => [ |
||
127 | 'username' => 'me', |
||
128 | 'password' => 'foobar', |
||
129 | 'ssl' => false, |
||
130 | ] |
||
131 | ], |
||
132 | 'file_options' => [ |
||
133 | 'path' => 'data/mail/output', |
||
134 | 'callback' => [], |
||
135 | ] |
||
136 | ] |
||
137 | ] |
||
138 | ]; |
||
139 | $this->assertEquals($expected, $this->service->parseConfig($oldConfig)); |
||
140 | } |
||
141 | |||
165 |