| Conditions | 7 |
| Paths | 33 |
| Total Lines | 64 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | 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 |
||
| 65 | * A module handler. |
||
| 66 | * @param \Drupal\Core\Form\FormBuilderInterface $form_builder |
||
| 67 | * The form builder service. |
||
| 68 | */ |
||
| 69 | <<<<<<< HEAD |
||
|
|
|||
| 70 | public function __construct(Database $database, LoggerInterface $logger, ModuleHandlerInterface $module_handler, FormBuilderInterface $form_builder) { |
||
| 71 | ======= |
||
| 72 | public function __construct(\MongoDB\database $database, Logger $logger, ModuleHandlerInterface $module_handler, FormBuilderInterface $form_builder) { |
||
| 73 | >>>>>>> 94b0d5d... Form, tabs and style, as close as possible to dblog code |
||
| 74 | $this->database = $database; |
||
| 75 | $this->logger = $logger; |
||
| 76 | $this->moduleHandler = $module_handler; |
||
| 77 | $this->formBuilder = $form_builder; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Controller for mongodb_watchdog.detail. |
||
| 82 | * |
||
| 83 | * @return array |
||
| 84 | * A render array. |
||
| 85 | */ |
||
| 86 | public function detail() { |
||
| 87 | return []; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Controller for mongodb_watchdog.overview. |
||
| 92 | * |
||
| 93 | * @return array |
||
| 94 | * A render array. |
||
| 95 | */ |
||
| 96 | public function overview() { |
||
| 97 | $icons = array( |
||
| 98 | LogLevel::DEBUG => '', |
||
| 99 | LogLevel::INFO => '', |
||
| 100 | LogLevel::NOTICE => '', |
||
| 101 | LogLevel::WARNING => ['#theme' => 'image', 'path' => 'misc/watchdog-warning.png', 'alt' => t('warning'), 'title' => t('warning')], |
||
| 102 | LogLevel::ERROR => ['#theme' => 'image', 'path' => 'misc/watchdog-error.png', 'alt' => t('error'), 'title' => t('error')], |
||
| 103 | LogLevel::CRITICAL => ['#theme' => 'image', 'path' => 'misc/watchdog-error.png', 'alt' => t('critical'), 'title' => t('critical')], |
||
| 104 | LogLevel::ALERT => ['#theme' => 'image', 'path' => 'misc/watchdog-error.png', 'alt' => t('alert'), 'title' => t('alert')], |
||
| 105 | LogLevel::EMERGENCY => ['#theme' => 'image', 'path' => 'misc/watchdog-error.png', 'alt' => t('emergency'), 'title' => t('emergency')], |
||
| 106 | ); |
||
| 107 | |||
| 108 | $collection = $this->database->selectCollection(Logger::TEMPLATE_COLLECTION); |
||
| 109 | $cursor = $collection->find(); |
||
| 110 | |||
| 111 | $this->moduleHandler->loadInclude('mongodb_watchdog', 'admin.inc'); |
||
| 112 | |||
| 113 | $build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\mongodb_watchdog\Form\MongodbWatchdogFilterForm'); |
||
| 114 | |||
| 115 | $header = array( |
||
| 116 | // Icon column. |
||
| 117 | '', |
||
| 118 | t('#'), |
||
| 119 | array('data' => t('Type')), |
||
| 120 | array('data' => t('Date')), |
||
| 121 | t('Source'), |
||
| 122 | t('Message'), |
||
| 123 | ); |
||
| 124 | |||
| 125 | $rows = array(); |
||
| 126 | |||
| 127 | foreach ($cursor as $id => $value) { |
||
| 128 | if ($id < 5) { |
||
| 129 | kint($value, $id); |
||
| 198 |