GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CreateDerivativesForm::submitForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Drupal\df_tools_image\Form;
4
5
use Drupal\Core\Form\FormBase;
6
use Drupal\Core\Form\FormStateInterface;
7
8
class CreateDerivativesForm extends FormBase {
9
10
  /**
11
   * {@inheritdoc}
12
   */
13
  public function getFormId() {
14
    return 'df_tools_image_settings';
15
  }
16
17
  /**
18
   * {@inheritdoc}
19
   */
20
  public function buildForm(array $form, FormStateInterface $form_state) {
21
22
    $styles = [];
23
24
    foreach (\Drupal\image\Entity\ImageStyle::loadMultiple() as $name => $style) {
25
      $styles[$name] = $style->label();
26
    }
27
28
    $form['description'] = [
29
      '#markup' => '<p>' . t('Image derivatives can be created in bulk manually to remove the need for Drupal to create them on page load.') . '</p>',
30
    ];
31
    $form['image_styles'] = [
32
      '#type' => 'checkboxes',
33
      '#options' => $styles,
34
      '#title' => $this->t('Which derivatives would you like to create?'),
35
      '#description' => $this->t('Select all image styles that should be created. If none are selected, all image derivatives will be created.'),
36
    ];
37
    $form['run'] = [
38
      '#type' => 'submit',
39
      '#value' => t('Create derivatives'),
40
    ];
41
42
    return $form;
43
  }
44
45
  /**
46
   * {@inheritdoc}
47
   */
48
  public function submitForm(array &$form, FormStateInterface $form_state) {
49
    $styles = array_diff(array_values($form_state->getValue('image_styles')), [0]);
50
    return df_tools_image_seed_derivatives('/', array(), $styles);
0 ignored issues
show
Bug introduced by
Are you sure the usage of df_tools_image_seed_deri...('/', array(), $styles) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
51
  }
52
}
53
54