From 58b23fe89d508a486540d791f3ab0ca9df03bbdf Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 15 Oct 2017 20:05:33 +0700 Subject: [PATCH] Removed useless code from models + code style fixes. --- ...2_added_language_and_per_page_for_user.php | 16 ++- .../20170321131931_add_environment.php | 24 +++- ...142131_added_tag_column_to_build_table.php | 8 +- ...20170828142020_added_remember_me_login.php | 8 +- ...170913141438_added_default_branch_only.php | 16 ++- src/PHPCensor/Model/Build.php | 106 ---------------- src/PHPCensor/Model/BuildError.php | 76 ----------- src/PHPCensor/Model/BuildMeta.php | 62 ++------- src/PHPCensor/Model/Environment.php | 76 ++--------- src/PHPCensor/Model/Project.php | 120 ++---------------- src/PHPCensor/Model/ProjectGroup.php | 38 +----- src/PHPCensor/Model/User.php | 78 ------------ 12 files changed, 85 insertions(+), 543 deletions(-) diff --git a/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php b/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php index b6352b19..befc77fd 100644 --- a/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php +++ b/src/PHPCensor/Migrations/20170103163312_added_language_and_per_page_for_user.php @@ -9,11 +9,15 @@ class AddedLanguageAndPerPageForUser extends AbstractMigration $table = $this->table('user'); if (!$table->hasColumn('language')) { - $table->addColumn('language', 'string', ['limit' => 5, 'null' => true])->save(); + $table + ->addColumn('language', 'string', ['limit' => 5, 'null' => true]) + ->save(); } if (!$table->hasColumn('per_page')) { - $table->addColumn('per_page', 'integer', ['null' => true])->save(); + $table + ->addColumn('per_page', 'integer', ['null' => true]) + ->save(); } } @@ -22,11 +26,15 @@ class AddedLanguageAndPerPageForUser extends AbstractMigration $table = $this->table('user'); if ($table->hasColumn('language')) { - $table->removeColumn('language')->save(); + $table + ->removeColumn('language') + ->save(); } if ($table->hasColumn('per_page')) { - $table->removeColumn('per_page')->save(); + $table + ->removeColumn('per_page') + ->save(); } } } diff --git a/src/PHPCensor/Migrations/20170321131931_add_environment.php b/src/PHPCensor/Migrations/20170321131931_add_environment.php index 890ac635..5d2b860d 100644 --- a/src/PHPCensor/Migrations/20170321131931_add_environment.php +++ b/src/PHPCensor/Migrations/20170321131931_add_environment.php @@ -13,25 +13,35 @@ class AddEnvironment extends AbstractMigration } if (!$table->hasColumn('project_id')) { - $table->addColumn('project_id', 'integer')->save(); + $table + ->addColumn('project_id', 'integer') + ->save(); } if (!$table->hasColumn('name')) { - $table->addColumn('name', 'string', ['limit' => 250])->save(); + $table + ->addColumn('name', 'string', ['limit' => 250]) + ->save(); } if (!$table->hasColumn('branches')) { - $table->addColumn('branches', 'text')->save(); + $table + ->addColumn('branches', 'text') + ->save(); } if (!$table->hasIndex(['project_id', 'name'])) { - $table->addIndex(['project_id', 'name'])->save(); + $table + ->addIndex(['project_id', 'name']) + ->save(); } $table = $this->table('build'); if (!$table->hasColumn('environment')) { - $table->addColumn('environment', 'string', ['limit' => 250])->save(); + $table + ->addColumn('environment', 'string', ['limit' => 250]) + ->save(); } } @@ -46,7 +56,9 @@ class AddEnvironment extends AbstractMigration $table = $this->table('build'); if ($table->hasColumn('environment')) { - $table->removeColumn('environment')->save(); + $table + ->removeColumn('environment') + ->save(); } } } diff --git a/src/PHPCensor/Migrations/20170420142131_added_tag_column_to_build_table.php b/src/PHPCensor/Migrations/20170420142131_added_tag_column_to_build_table.php index cc5f80e5..39b752ad 100644 --- a/src/PHPCensor/Migrations/20170420142131_added_tag_column_to_build_table.php +++ b/src/PHPCensor/Migrations/20170420142131_added_tag_column_to_build_table.php @@ -9,7 +9,9 @@ class AddedTagColumnToBuildTable extends AbstractMigration $table = $this->table('build'); if (!$table->hasColumn('tag')) { - $table->addColumn('tag', 'string', ['limit' => 250, 'null' => true])->save(); + $table + ->addColumn('tag', 'string', ['limit' => 250, 'null' => true]) + ->save(); } } @@ -18,7 +20,9 @@ class AddedTagColumnToBuildTable extends AbstractMigration $table = $this->table('build'); if ($table->hasColumn('tag')) { - $table->removeColumn('tag')->save(); + $table + ->removeColumn('tag') + ->save(); } } } diff --git a/src/PHPCensor/Migrations/20170828142020_added_remember_me_login.php b/src/PHPCensor/Migrations/20170828142020_added_remember_me_login.php index 0dc4e075..da88adc7 100644 --- a/src/PHPCensor/Migrations/20170828142020_added_remember_me_login.php +++ b/src/PHPCensor/Migrations/20170828142020_added_remember_me_login.php @@ -9,7 +9,9 @@ class AddedRememberMeLogin extends AbstractMigration $table = $this->table('user'); if (!$table->hasColumn('remember_key')) { - $table->addColumn('remember_key', 'string', ['limit' => 32, 'null' => true])->save(); + $table + ->addColumn('remember_key', 'string', ['limit' => 32, 'null' => true]) + ->save(); } } @@ -18,7 +20,9 @@ class AddedRememberMeLogin extends AbstractMigration $table = $this->table('user'); if ($table->hasColumn('remember_key')) { - $table->removeColumn('remember_key')->save(); + $table + ->removeColumn('remember_key') + ->save(); } } } diff --git a/src/PHPCensor/Migrations/20170913141438_added_default_branch_only.php b/src/PHPCensor/Migrations/20170913141438_added_default_branch_only.php index 64352cee..af125714 100644 --- a/src/PHPCensor/Migrations/20170913141438_added_default_branch_only.php +++ b/src/PHPCensor/Migrations/20170913141438_added_default_branch_only.php @@ -6,19 +6,23 @@ class AddedDefaultBranchOnly extends AbstractMigration { public function up() { - $project = $this->table('project'); + $table = $this->table('project'); - if (!$project->hasColumn('default_branch_only')) { - $project->addColumn('default_branch_only', 'integer', ['default' => 0])->save(); + if (!$table->hasColumn('default_branch_only')) { + $table + ->addColumn('default_branch_only', 'integer', ['default' => 0]) + ->save(); } } public function down() { - $project = $this->table('project'); + $table = $this->table('project'); - if ($project->hasColumn('default_branch_only')) { - $project->removeColumn('default_branch_only')->save(); + if ($table->hasColumn('default_branch_only')) { + $table + ->removeColumn('default_branch_only') + ->save(); } } } diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index ade8e1cc..4c62d4c3 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -118,112 +118,6 @@ class Build extends Model 'Project' => 'setProject', ]; - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'project_id' => [ - 'type' => 'int', - 'length' => 11, - 'default' => null, - ], - 'commit_id' => [ - 'type' => 'varchar', - 'length' => 50, - 'default' => null, - ], - 'status' => [ - 'type' => 'int', - 'length' => 11, - 'default' => null, - ], - 'log' => [ - 'type' => 'mediumtext', - 'nullable' => true, - 'default' => null, - ], - 'branch' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => 'master', - ], - 'tag' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'created' => [ - 'type' => 'datetime', - 'nullable' => true, - 'default' => null, - ], - 'started' => [ - 'type' => 'datetime', - 'nullable' => true, - 'default' => null, - ], - 'finished' => [ - 'type' => 'datetime', - 'nullable' => true, - 'default' => null, - ], - 'committer_email' => [ - 'type' => 'varchar', - 'length' => 512, - 'nullable' => true, - 'default' => null, - ], - 'commit_message' => [ - 'type' => 'text', - 'nullable' => true, - 'default' => null, - ], - 'extra' => [ - 'type' => 'text', - 'nullable' => true, - 'default' => null, - ], - 'environment' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'source' => [ - 'type' => 'int', - 'length' => 11, - 'default' => Build::SOURCE_UNKNOWN, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - 'project_id' => ['columns' => 'project_id'], - 'idx_status' => ['columns' => 'status'], - ]; - - /** - * @var array - */ - public $foreignKeys = [ - 'build_ibfk_1' => [ - 'local_col' => 'project_id', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - 'table' => 'project', - 'col' => 'id' - ], - ]; - /** * Get the value of Id / id. * diff --git a/src/PHPCensor/Model/BuildError.php b/src/PHPCensor/Model/BuildError.php index 7a1f70a6..135aeecc 100644 --- a/src/PHPCensor/Model/BuildError.php +++ b/src/PHPCensor/Model/BuildError.php @@ -75,82 +75,6 @@ class BuildError extends Model 'Build' => 'setBuild', ]; - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'build_id' => [ - 'type' => 'int', - 'length' => 11, - 'default' => null, - ], - 'plugin' => [ - 'type' => 'varchar', - 'length' => 100, - 'default' => null, - ], - 'file' => [ - 'type' => 'varchar', - 'length' => 250, - 'nullable' => true, - 'default' => null, - ], - 'line_start' => [ - 'type' => 'int', - 'length' => 11, - 'nullable' => true, - 'default' => null, - ], - 'line_end' => [ - 'type' => 'int', - 'length' => 11, - 'nullable' => true, - 'default' => null, - ], - 'severity' => [ - 'type' => 'tinyint', - 'length' => 3, - 'default' => null, - ], - 'message' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'created_date' => [ - 'type' => 'datetime', - 'default' => null, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - 'build_id' => ['columns' => 'build_id, created_date'], - ]; - - /** - * @var array - */ - public $foreignKeys = [ - 'build_error_ibfk_1' => [ - 'local_col' => 'build_id', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - 'table' => 'build', - 'col' => 'id' - ], - ]; - /** * Get the value of Id / id. * diff --git a/src/PHPCensor/Model/BuildMeta.php b/src/PHPCensor/Model/BuildMeta.php index 14e8e035..7ef1475e 100644 --- a/src/PHPCensor/Model/BuildMeta.php +++ b/src/PHPCensor/Model/BuildMeta.php @@ -41,8 +41,9 @@ class BuildMeta extends Model 'build_id' => 'getBuildId', 'meta_key' => 'getMetaKey', 'meta_value' => 'getMetaValue', + // Foreign key getters: - 'Build' => 'getBuild', + 'Build' => 'getBuild', ]; /** @@ -54,56 +55,9 @@ class BuildMeta extends Model 'build_id' => 'setBuildId', 'meta_key' => 'setMetaKey', 'meta_value' => 'setMetaValue', + // Foreign key setters: - 'Build' => 'setBuild', - ]; - - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 10, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'build_id' => [ - 'type' => 'int', - 'length' => 11, - 'default' => null, - ], - 'meta_key' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'meta_value' => [ - 'type' => 'mediumtext', - 'default' => null, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - 'idx_meta_id' => ['unique' => true, 'columns' => 'build_id, meta_key'], - ]; - - /** - * @var array - */ - public $foreignKeys = [ - 'fk_meta_build_id' => [ - 'local_col' => 'build_id', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - 'table' => 'build', - 'col' => 'id' - ], + 'Build' => 'setBuild', ]; /** @@ -113,7 +67,7 @@ class BuildMeta extends Model */ public function getId() { - $rtn = $this->data['id']; + $rtn = $this->data['id']; return $rtn; } @@ -125,7 +79,7 @@ class BuildMeta extends Model */ public function getBuildId() { - $rtn = $this->data['build_id']; + $rtn = $this->data['build_id']; return $rtn; } @@ -137,7 +91,7 @@ class BuildMeta extends Model */ public function getMetaKey() { - $rtn = $this->data['meta_key']; + $rtn = $this->data['meta_key']; return $rtn; } @@ -149,7 +103,7 @@ class BuildMeta extends Model */ public function getMetaValue() { - $rtn = $this->data['meta_value']; + $rtn = $this->data['meta_value']; return $rtn; } diff --git a/src/PHPCensor/Model/Environment.php b/src/PHPCensor/Model/Environment.php index 4645010c..ece87a98 100644 --- a/src/PHPCensor/Model/Environment.php +++ b/src/PHPCensor/Model/Environment.php @@ -25,82 +25,30 @@ class Environment extends Model * @var array */ protected $data = [ - 'id' => null, + 'id' => null, 'project_id' => null, - 'name' => null, - 'branches' => null, + 'name' => null, + 'branches' => null, ]; /** * @var array */ protected $getters = [ - // Direct property getters: - 'id' => 'getId', + 'id' => 'getId', 'project_id' => 'getProjectId', - 'name' => 'getName', - 'branches' => 'getBranches', - // Foreign key getters: + 'name' => 'getName', + 'branches' => 'getBranches', ]; /** * @var array */ protected $setters = [ - // Direct property setters: - 'id' => 'setId', - 'project_id' => 'setProjectId', - 'name' => 'setName', - 'branches' => 'setBranches', - // Foreign key setters: - ]; - - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'project_id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'default' => null, - ], - 'name' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'branches' => [ - 'type' => 'text', - 'default' => '', - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'project_id, name'], - ]; - - /** - * @var array - */ - public $foreignKeys = [ - 'environment_ibfk_1' => [ - 'local_col' => 'project_id', - 'update' => 'CASCADE', - 'delete' => '', - 'table' => 'project', - 'col' => 'id' - ], + 'id' => 'setId', + 'project_id' => 'setProjectId', + 'name' => 'setName', + 'branches' => 'setBranches', ]; /** @@ -110,7 +58,7 @@ class Environment extends Model */ public function getId() { - $rtn = $this->data['id']; + $rtn = $this->data['id']; return $rtn; } @@ -134,7 +82,7 @@ class Environment extends Model */ public function getName() { - $rtn = $this->data['name']; + $rtn = $this->data['name']; return $rtn; } diff --git a/src/PHPCensor/Model/Project.php b/src/PHPCensor/Model/Project.php index 406df493..9276d0ee 100644 --- a/src/PHPCensor/Model/Project.php +++ b/src/PHPCensor/Model/Project.php @@ -68,8 +68,9 @@ class Project extends Model 'allow_public_status' => 'getAllowPublicStatus', 'archived' => 'getArchived', 'group_id' => 'getGroupId', + // Foreign key getters: - 'Group' => 'getGroup', + 'Group' => 'getGroup', ]; /** @@ -91,108 +92,9 @@ class Project extends Model 'allow_public_status' => 'setAllowPublicStatus', 'archived' => 'setArchived', 'group_id' => 'setGroupId', + // Foreign key setters: - 'Group' => 'setGroup', - ]; - - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'title' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'reference' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'branch' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => 'master', - ], - 'default_branch_only' => [ - 'type' => 'int', - 'length' => 11, - ], - 'ssh_private_key' => [ - 'type' => 'text', - 'nullable' => true, - 'default' => null, - ], - 'type' => [ - 'type' => 'varchar', - 'length' => 50, - 'default' => null, - ], - 'access_information' => [ - 'type' => 'varchar', - 'length' => 250, - 'nullable' => true, - 'default' => null, - ], - 'last_commit' => [ - 'type' => 'varchar', - 'length' => 250, - 'nullable' => true, - 'default' => null, - ], - 'build_config' => [ - 'type' => 'text', - 'nullable' => true, - 'default' => null, - ], - 'ssh_public_key' => [ - 'type' => 'text', - 'nullable' => true, - 'default' => null, - ], - 'allow_public_status' => [ - 'type' => 'int', - 'length' => 11, - ], - 'archived' => [ - 'type' => 'tinyint', - 'length' => 1, - 'default' => null, - ], - 'group_id' => [ - 'type' => 'int', - 'length' => 11, - 'default' => 1, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - 'idx_project_title' => ['columns' => 'title'], - 'group_id' => ['columns' => 'group_id'], - ]; - - /** - * @var array - */ - public $foreignKeys = [ - 'project_ibfk_1' => [ - 'local_col' => 'group_id', - 'update' => 'CASCADE', - 'delete' => '', - 'table' => 'project_group', - 'col' => 'id' - ], + 'Group' => 'setGroup', ]; /** @@ -202,7 +104,7 @@ class Project extends Model */ public function getId() { - $rtn = $this->data['id']; + $rtn = $this->data['id']; return $rtn; } @@ -214,7 +116,7 @@ class Project extends Model */ public function getTitle() { - $rtn = $this->data['title']; + $rtn = $this->data['title']; return $rtn; } @@ -226,7 +128,7 @@ class Project extends Model */ public function getReference() { - $rtn = $this->data['reference']; + $rtn = $this->data['reference']; return $rtn; } @@ -238,7 +140,7 @@ class Project extends Model */ public function getSshPrivateKey() { - $rtn = $this->data['ssh_private_key']; + $rtn = $this->data['ssh_private_key']; return $rtn; } @@ -250,7 +152,7 @@ class Project extends Model */ public function getType() { - $rtn = $this->data['type']; + $rtn = $this->data['type']; return $rtn; } @@ -262,7 +164,7 @@ class Project extends Model */ public function getLastCommit() { - $rtn = $this->data['last_commit']; + $rtn = $this->data['last_commit']; return $rtn; } @@ -286,7 +188,7 @@ class Project extends Model */ public function getSshPublicKey() { - $rtn = $this->data['ssh_public_key']; + $rtn = $this->data['ssh_public_key']; return $rtn; } diff --git a/src/PHPCensor/Model/ProjectGroup.php b/src/PHPCensor/Model/ProjectGroup.php index 3d5adf16..904f1e81 100644 --- a/src/PHPCensor/Model/ProjectGroup.php +++ b/src/PHPCensor/Model/ProjectGroup.php @@ -34,52 +34,18 @@ class ProjectGroup extends Model * @var array */ protected $getters = [ - // Direct property getters: 'id' => 'getId', 'title' => 'getTitle', - // Foreign key getters: ]; /** * @var array */ protected $setters = [ - // Direct property setters: 'id' => 'setId', 'title' => 'setTitle', - // Foreign key setters: ]; - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'title' => [ - 'type' => 'varchar', - 'length' => 100, - 'default' => null, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - ]; - - /** - * @var array - */ - public $foreignKeys = []; - /** * Get the value of Id / id. * @@ -87,7 +53,7 @@ class ProjectGroup extends Model */ public function getId() { - $rtn = $this->data['id']; + $rtn = $this->data['id']; return $rtn; } @@ -99,7 +65,7 @@ class ProjectGroup extends Model */ public function getTitle() { - $rtn = $this->data['title']; + $rtn = $this->data['title']; return $rtn; } diff --git a/src/PHPCensor/Model/User.php b/src/PHPCensor/Model/User.php index 204d81fd..fc466743 100644 --- a/src/PHPCensor/Model/User.php +++ b/src/PHPCensor/Model/User.php @@ -45,7 +45,6 @@ class User extends Model * @var array */ protected $getters = [ - // Direct property getters: 'id' => 'getId', 'email' => 'getEmail', 'hash' => 'getHash', @@ -56,14 +55,12 @@ class User extends Model 'provider_key' => 'getProviderKey', 'provider_data' => 'getProviderData', 'remember_key' => 'getRememberKey', - // Foreign key getters: ]; /** * @var array */ protected $setters = [ - // Direct property setters: 'id' => 'setId', 'email' => 'setEmail', 'hash' => 'setHash', @@ -74,83 +71,8 @@ class User extends Model 'provider_key' => 'setProviderKey', 'provider_data' => 'setProviderData', 'remember_key' => 'setRememberKey', - // Foreign key setters: ]; - /** - * @var array - */ - public $columns = [ - 'id' => [ - 'type' => 'int', - 'length' => 11, - 'primary_key' => true, - 'auto_increment' => true, - 'default' => null, - ], - 'email' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'hash' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'is_admin' => [ - 'type' => 'int', - 'length' => 11, - ], - 'name' => [ - 'type' => 'varchar', - 'length' => 250, - 'default' => null, - ], - 'language' => [ - 'type' => 'varchar', - 'length' => 5, - 'default' => null, - ], - 'per_page' => [ - 'type' => 'int', - 'length' => 11, - 'default' => null, - ], - 'provider_key' => [ - 'type' => 'varchar', - 'length' => 255, - 'default' => 'internal', - ], - 'provider_data' => [ - 'type' => 'varchar', - 'length' => 255, - 'nullable' => true, - 'default' => null, - ], - 'remember_key' => [ - 'type' => 'varchar', - 'length' => 32, - 'nullable' => true, - 'default' => null, - ], - ]; - - /** - * @var array - */ - public $indexes = [ - 'PRIMARY' => ['unique' => true, 'columns' => 'id'], - 'idx_email' => ['unique' => true, 'columns' => 'email'], - 'email' => ['unique' => true, 'columns' => 'email'], - 'name' => ['columns' => 'name'], - ]; - - /** - * @var array - */ - public $foreignKeys = []; - /** * Get the value of Id / id. *