| Conditions | 1 |
| Paths | 1 |
| Total Lines | 121 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 declare(strict_types=1); |
||
| 108 | public function testWrite(array &$files = []) |
||
| 109 | { |
||
| 110 | $this->baseEntityClassWriter->write($this->dmsDatabase, $this->dmsTable, $files); |
||
| 111 | |||
| 112 | $baseEntityFilePath = \implode( |
||
| 113 | '', |
||
| 114 | [ |
||
| 115 | $this->dmsGeneratedDirectory, |
||
| 116 | DIRECTORY_SEPARATOR, |
||
| 117 | \sprintf('%s%s.php', $this->writerConfig->getClassPrefix(), $this->dmsTable->getPhpName()) |
||
| 118 | ] |
||
| 119 | ); |
||
| 120 | $this->assertFileExists($baseEntityFilePath); |
||
| 121 | $this->assertEquals( |
||
| 122 | /** @lang PHP */ |
||
| 123 | <<<PHP |
||
| 124 | <?php declare(strict_types=1); |
||
| 125 | |||
| 126 | namespace None\Existent\Namespace\DatabaseNameSnakeCase\Base; |
||
| 127 | |||
| 128 | use Janisbiz\LightOrm\Entity\BaseEntity; |
||
| 129 | |||
| 130 | class BaseTableNameSnakeCase4 extends BaseEntity |
||
| 131 | { |
||
| 132 | const DATABASE_NAME = 'database_name_snake_case'; |
||
| 133 | const TABLE_NAME = 'database_name_snake_case.table_name_snake_case_4'; |
||
| 134 | |||
| 135 | const COLUMN_NAME_SNAKE_CASE_1 = 'name_snake_case_1'; |
||
| 136 | const COLUMN_NAME_SNAKE_CASE_2 = 'name_snake_case_2'; |
||
| 137 | const COLUMN_NAME_SNAKE_CASE_3 = 'name_snake_case_3'; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @param bool \$isNew |
||
| 141 | */ |
||
| 142 | public function __construct(\$isNew = true) |
||
| 143 | { |
||
| 144 | \$this->primaryKeys = [ |
||
| 145 | static::COLUMN_NAME_SNAKE_CASE_1, |
||
| 146 | static::COLUMN_NAME_SNAKE_CASE_2, |
||
| 147 | ]; |
||
| 148 | \$this->primaryKeysAutoIncrement = [ |
||
| 149 | static::COLUMN_NAME_SNAKE_CASE_1, |
||
| 150 | ]; |
||
| 151 | \$this->columns = [ |
||
| 152 | static::COLUMN_NAME_SNAKE_CASE_1, |
||
| 153 | static::COLUMN_NAME_SNAKE_CASE_2, |
||
| 154 | static::COLUMN_NAME_SNAKE_CASE_3, |
||
| 155 | ]; |
||
| 156 | |||
| 157 | \$this->isNew = \$isNew; |
||
| 158 | if (empty(\$this->data)) { |
||
| 159 | \$this->isNew = true; |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @return null|string |
||
| 165 | */ |
||
| 166 | public function getNameSnakeCase1(): ?string |
||
| 167 | { |
||
| 168 | return \$this->data['name_snake_case_1']; |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @param null|string \$nameSnakeCase1 |
||
| 173 | * |
||
| 174 | * @return \$this |
||
| 175 | */ |
||
| 176 | public function setNameSnakeCase1(?string \$nameSnakeCase1): BaseTableNameSnakeCase4 |
||
| 177 | { |
||
| 178 | \$this->data['name_snake_case_1'] = \$nameSnakeCase1; |
||
| 179 | |||
| 180 | return \$this; |
||
| 181 | } |
||
| 182 | |||
| 183 | |||
| 184 | /** |
||
| 185 | * @return null|string |
||
| 186 | */ |
||
| 187 | public function getNameSnakeCase2(): ?string |
||
| 188 | { |
||
| 189 | return \$this->data['name_snake_case_2']; |
||
| 190 | } |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @param null|string \$nameSnakeCase2 |
||
| 194 | * |
||
| 195 | * @return \$this |
||
| 196 | */ |
||
| 197 | public function setNameSnakeCase2(?string \$nameSnakeCase2): BaseTableNameSnakeCase4 |
||
| 198 | { |
||
| 199 | \$this->data['name_snake_case_2'] = \$nameSnakeCase2; |
||
| 200 | |||
| 201 | return \$this; |
||
| 202 | } |
||
| 203 | |||
| 204 | |||
| 205 | /** |
||
| 206 | * @return null|string |
||
| 207 | */ |
||
| 208 | public function getNameSnakeCase3(): ?string |
||
| 209 | { |
||
| 210 | return \$this->data['name_snake_case_3']; |
||
| 211 | } |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @param null|string \$nameSnakeCase3 |
||
| 215 | * |
||
| 216 | * @return \$this |
||
| 217 | */ |
||
| 218 | public function setNameSnakeCase3(?string \$nameSnakeCase3): BaseTableNameSnakeCase4 |
||
| 219 | { |
||
| 220 | \$this->data['name_snake_case_3'] = \$nameSnakeCase3; |
||
| 221 | |||
| 222 | return \$this; |
||
| 223 | } |
||
| 224 | } |
||
| 225 | |||
| 226 | PHP |
||
| 227 | , |
||
| 228 | \file_get_contents($baseEntityFilePath) |
||
| 229 | ); |
||
| 258 |