Conditions | 1 |
Total Lines | 53 |
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 |
||
89 | private function createMockMessage(): \Ecodev\Felix\Model\Message |
||
90 | { |
||
91 | return new class() implements \Ecodev\Felix\Model\Message { |
||
92 | /** |
||
93 | * @var null|Chronos |
||
94 | */ |
||
95 | private $dateSent; |
||
96 | |||
97 | public function getSubject(): string |
||
98 | { |
||
99 | return 'my subject'; |
||
100 | } |
||
101 | |||
102 | public function getBody(): string |
||
103 | { |
||
104 | return 'my body'; |
||
105 | } |
||
106 | |||
107 | public function setDateSent(?Chronos $dateSent): void |
||
108 | { |
||
109 | $this->dateSent = $dateSent; |
||
110 | } |
||
111 | |||
112 | public function getEmail(): string |
||
113 | { |
||
114 | return '[email protected]'; |
||
115 | } |
||
116 | |||
117 | public function getRecipient(): ?User |
||
118 | { |
||
119 | return null; |
||
120 | } |
||
121 | |||
122 | public function getId(): ?int |
||
123 | { |
||
124 | return null; |
||
125 | } |
||
126 | |||
127 | public function setSubject(string $subject): void |
||
128 | { |
||
129 | } |
||
130 | |||
131 | public function setBody(string $body): void |
||
132 | { |
||
133 | } |
||
134 | |||
135 | public function getDateSent(): ?Chronos |
||
136 | { |
||
137 | return $this->dateSent; |
||
138 | } |
||
139 | |||
140 | public function setEmail(string $email): void |
||
141 | { |
||
142 | // TODO: Implement setEmail() method. |
||
147 |