Conditions | 10 |
Paths | 4 |
Total Lines | 38 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
66 | public function callbackAction() |
||
67 | { |
||
68 | $message = 'flashes.import.notice.failed'; |
||
69 | $pocket = $this->getPocketImportService(); |
||
70 | |||
71 | $markAsRead = $this->get('session')->get('mark_as_read'); |
||
72 | $this->get('session')->remove('mark_as_read'); |
||
73 | |||
74 | // something bad happend on pocket side |
||
75 | if (false === $pocket->authorize($this->get('session')->get('import.pocket.code'))) { |
||
76 | $this->get('session')->getFlashBag()->add( |
||
77 | 'notice', |
||
78 | $message |
||
79 | ); |
||
80 | |||
81 | return $this->redirect($this->generateUrl('import_pocket')); |
||
82 | } |
||
83 | |||
84 | if (true === $pocket->setMarkAsRead($markAsRead)->import()) { |
||
85 | $summary = $pocket->getSummary(); |
||
86 | $message = $this->get('translator')->trans('flashes.import.notice.summary', [ |
||
87 | '%imported%' => null !== $summary && \array_key_exists('imported', $summary) ? $summary['imported'] : 0, |
||
88 | '%skipped%' => null !== $summary && \array_key_exists('skipped', $summary) ? $summary['skipped'] : 0, |
||
89 | ]); |
||
90 | |||
91 | if (null !== $summary && \array_key_exists('queued', $summary) && 0 < $summary['queued']) { |
||
92 | $message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [ |
||
93 | '%queued%' => $summary['queued'], |
||
94 | ]); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | $this->get('session')->getFlashBag()->add( |
||
99 | 'notice', |
||
100 | $message |
||
101 | ); |
||
102 | |||
103 | return $this->redirect($this->generateUrl('homepage')); |
||
104 | } |
||
125 |