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.

AuthorMigrationTrait::setUidProperty()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 14
rs 10
cc 3
nc 3
nop 3
1
<?php
2
3
namespace Drupal\df_tools_migration\Plugin\migrate\source;
4
5
use Drupal\migrate\Row;
6
7
/**
8
 * Provides shared methods for processing image migrations in Source Plugins.
9
 */
10
trait AuthorMigrationTrait {
11
12
  /**
13
   * Configuration information passed into the plugin.
14
   *
15
   * @var array
16
   */
17
  protected $configuration;
18
19
  /**
20
   * The entity migration object.
21
   *
22
   * @var \Drupal\migrate\Entity\MigrationInterface
0 ignored issues
show
Bug introduced by
The type Drupal\migrate\Entity\MigrationInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
   */
24
  protected $migration;
25
26
  /**
27
   * Sets the UID property for the migration target, optionally
28
   * accepting a null UID and role-based lookup with
29
   * random author assignment.
30
   *
31
   * @param \Drupal\migrate\Row $row
32
   * @param null $uid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $uid is correct as it would always require null to be passed?
Loading history...
33
   * @param string $roles
34
   */
35
  protected function setUidProperty(Row $row, $uid = NULL, $roles = 'administrator') {
36
    if ($uid == NULL) {
0 ignored issues
show
introduced by
The condition $uid == NULL is always true.
Loading history...
37
      $request_users = \Drupal::entityTypeManager()
38
        ->getStorage('user')
39
        ->loadByProperties([
40
          'roles' => $roles,
41
        ]);
42
43
      if ($request_users) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $request_users of type Drupal\Core\Entity\EntityInterface[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
44
        $uid = array_rand($request_users);
45
      }
46
    }
47
48
    $row->setSourceProperty('UID', $uid);
49
  }
50
51
}
52