| Conditions | 5 |
| Paths | 3 |
| Total Lines | 68 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 75 | public function up(Schema $schema) |
||
| 76 | { |
||
| 77 | $parameters = Parameters::parseFile(static::DIRECTORY.'/parameters.yaml'); |
||
| 78 | $this->acl->up($schema, Objects::parseFile(static::DIRECTORY.'/0_15_0/acl.yaml', $parameters)); |
||
| 79 | $this->config->setContainer($this->container)->up($schema, Objects::parseFile(static::DIRECTORY.'/0_15_0/config.yaml', $parameters)); |
||
| 80 | $this->metadata->up($schema, Objects::parseFile(static::DIRECTORY.'/0_15_0/metadata.yaml', $parameters)); |
||
| 81 | $this->parameter->setContainer($this->container)->up($schema, Objects::parseFile(static::DIRECTORY.'/0_15_0/system/parameter.yaml', $parameters)); |
||
| 82 | $this->tenant->up($schema, Objects::parseFile(static::DIRECTORY.'/0_15_0/system/tenant.yaml', $parameters)); |
||
| 83 | |||
| 84 | $users = Objects::parseFile(static::DIRECTORY.'/0_15_0/user.yaml', $parameters); |
||
| 85 | |||
| 86 | $sequences['app_registration_id_seq'] = 1; |
||
| 87 | $sequences['app_user_id_seq'] = 1 + count($users); |
||
| 88 | |||
| 89 | switch ($this->platform->getName()) { |
||
| 90 | case 'postgresql': |
||
| 91 | $this->addSql('CREATE SEQUENCE app_registration_id_seq INCREMENT BY 1 MINVALUE 1 START '.$sequences['app_registration_id_seq']); |
||
| 92 | $this->addSql('CREATE SEQUENCE app_user_id_seq INCREMENT BY 1 MINVALUE 1 START '.$sequences['app_user_id_seq']); |
||
| 93 | $this->addSql('CREATE TABLE app_registration (id INT NOT NULL, user_id INT DEFAULT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, username VARCHAR(255) NOT NULL, identity VARCHAR(255) DEFAULT NULL, data JSON NOT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
| 94 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26D17F50A6 ON app_registration (uuid)'); |
||
| 95 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26A76ED395 ON app_registration (user_id)'); |
||
| 96 | $this->addSql('CREATE UNIQUE INDEX UNIQ_A026BD26F85E06774E59C462 ON app_registration (username, tenant)'); |
||
| 97 | $this->addSql('COMMENT ON COLUMN app_registration.data IS \'(DC2Type:json_array)\''); |
||
| 98 | $this->addSql('CREATE TABLE app_user (id INT NOT NULL, username VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, salt VARCHAR(255) DEFAULT NULL, password VARCHAR(255) NOT NULL, last_login TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, password_requested_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, roles TEXT NOT NULL, uuid UUID NOT NULL, "owner" VARCHAR(255) DEFAULT NULL, owner_uuid UUID DEFAULT NULL, identity VARCHAR(255) DEFAULT NULL, identity_uuid UUID DEFAULT NULL, version INT DEFAULT 1 NOT NULL, tenant UUID NOT NULL, username_canonical VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))'); |
||
| 99 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9C05FB297 ON app_user (confirmation_token)'); |
||
| 100 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9D17F50A6 ON app_user (uuid)'); |
||
| 101 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9F85E06774E59C462 ON app_user (username, tenant)'); |
||
| 102 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E992FC23A84E59C462 ON app_user (username_canonical, tenant)'); |
||
| 103 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9E7927C744E59C462 ON app_user (email, tenant)'); |
||
| 104 | $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E9A0D96FBF4E59C462 ON app_user (email_canonical, tenant)'); |
||
| 105 | $this->addSql('COMMENT ON COLUMN app_user.roles IS \'(DC2Type:array)\''); |
||
| 106 | $this->addSql('ALTER TABLE app_registration ADD CONSTRAINT FK_A026BD26A76ED395 FOREIGN KEY (user_id) REFERENCES app_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 107 | |||
| 108 | $i = 0; |
||
| 109 | |||
| 110 | foreach ($users as $user) { |
||
| 111 | $this->addSql(sprintf( |
||
| 112 | 'INSERT INTO app_user (id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, uuid, owner, owner_uuid, identity, identity_uuid, version, tenant, created_at, updated_at, deleted_at) VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s);', |
||
| 113 | ++$i, |
||
| 114 | $this->connection->quote($user->username), |
||
| 115 | $this->connection->quote($user->username), |
||
| 116 | $this->connection->quote($user->username), |
||
| 117 | $this->connection->quote($user->username), |
||
| 118 | $user->enabled ? 'true' : 'false', |
||
| 119 | 'NULL', |
||
| 120 | $this->connection->quote(password_hash($user->password, PASSWORD_BCRYPT)), |
||
| 121 | 'NULL', |
||
| 122 | 'NULL', |
||
| 123 | 'NULL', |
||
| 124 | $this->connection->quote(serialize($user->roles)), |
||
| 125 | $this->connection->quote($user->uuid), |
||
| 126 | $this->connection->quote($user->owner), |
||
| 127 | $this->connection->quote($user->owner_uuid), |
||
| 128 | $this->connection->quote($user->identity), |
||
| 129 | null === $user->identity_uuid ? 'NULL' : $this->connection->quote($user->identity_uuid), |
||
| 130 | $user->version, |
||
| 131 | $this->connection->quote($user->tenant), |
||
| 132 | 'now()', |
||
| 133 | 'now()', |
||
| 134 | 'NULL' |
||
| 135 | )); |
||
| 136 | } |
||
| 137 | |||
| 138 | break; |
||
| 139 | |||
| 140 | default: |
||
| 141 | $this->abortIf(true,'Migration cannot be executed on "'.$this->platform->getName().'".'); |
||
| 142 | break; |
||
| 143 | } |
||
| 174 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths