Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 22 | abstract class Base extends PHPUnit_Framework_TestCase |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var \eZ\Publish\Core\Repository\Repository |
||
| 26 | */ |
||
| 27 | protected $repository; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Setup test. |
||
| 31 | */ |
||
| 32 | protected function setUp() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Returns User stub with $id as User/Content id. |
||
| 41 | * |
||
| 42 | * @param int $id |
||
| 43 | * |
||
| 44 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 45 | */ |
||
| 46 | View Code Duplication | protected function getStubbedUser($id) |
|
| 63 | |||
| 64 | /** |
||
| 65 | * @return \eZ\Publish\Core\Repository\Values\User\User |
||
| 66 | */ |
||
| 67 | View Code Duplication | protected function createUserVersion1() |
|
| 99 | |||
| 100 | /** |
||
| 101 | * Tear down test (properties). |
||
| 102 | */ |
||
| 103 | protected function tearDown() |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Generate \eZ\Publish\API\Repository\Repository. |
||
| 111 | * |
||
| 112 | * Makes it possible to inject different Io / Persistence handlers |
||
| 113 | * |
||
| 114 | * @return \eZ\Publish\API\Repository\Repository |
||
| 115 | */ |
||
| 116 | abstract protected function getRepository(); |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Asserts that properties given in $expectedValues are correctly set in |
||
| 120 | * $actualObject. |
||
| 121 | * |
||
| 122 | * @param mixed[] $expectedValues |
||
| 123 | * @param \eZ\Publish\API\Repository\Values\ValueObject $actualObject |
||
| 124 | * @param array $skipProperties |
||
| 125 | */ |
||
| 126 | View Code Duplication | protected function assertPropertiesCorrect(array $expectedValues, ValueObject $actualObject, array $skipProperties = array()) |
|
| 136 | |||
| 137 | View Code Duplication | protected function assertSameClassPropertiesCorrect( |
|
| 152 | |||
| 153 | /** |
||
| 154 | * Asserts all properties from $expectedValues are correctly set in |
||
| 155 | * $actualObject. |
||
| 156 | * |
||
| 157 | * @param \eZ\Publish\API\Repository\Values\ValueObject $expectedValues |
||
| 158 | * @param \eZ\Publish\API\Repository\Values\ValueObject $actualObject |
||
| 159 | * @param array $skipProperties |
||
| 160 | */ |
||
| 161 | View Code Duplication | protected function assertStructPropertiesCorrect(ValueObject $expectedValues, ValueObject $actualObject, array $skipProperties = array()) |
|
| 171 | |||
| 172 | private function assertProperty($propertyName, $expectedValue, $actualValue, $equal = true) |
||
| 203 | |||
| 204 | protected function getDateTime($timestamp) |
||
| 211 | } |
||
| 212 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.