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  | 
            ||
| 20 | class RouteBasedLimitationParser extends BaseParser  | 
            ||
| 21 | { | 
            ||
| 22 | /**  | 
            ||
| 23 | * Name of the route parameter.  | 
            ||
| 24 | * Example: "sectionId".  | 
            ||
| 25 | * @var string  | 
            ||
| 26 | */  | 
            ||
| 27 | private $limitationRouteParameterName;  | 
            ||
| 28 | |||
| 29 | /**  | 
            ||
| 30 | * Value object class built by the Parser.  | 
            ||
| 31 | * Example: "eZ\Publish\API\Repository\Values\User\Limitation\SectionLimitation".  | 
            ||
| 32 | * @var string  | 
            ||
| 33 | */  | 
            ||
| 34 | private $limitationClass;  | 
            ||
| 35 | |||
| 36 | /**  | 
            ||
| 37 | * LimitationParser constructor.  | 
            ||
| 38 | *  | 
            ||
| 39 | * @param string $limitationRouteParameterName  | 
            ||
| 40 | * @param string $limitationClass  | 
            ||
| 41 | */  | 
            ||
| 42 | public function __construct($limitationRouteParameterName, $limitationClass)  | 
            ||
| 47 | |||
| 48 | /**  | 
            ||
| 49 | * Parse input structure.  | 
            ||
| 50 | *  | 
            ||
| 51 | * @param array $data  | 
            ||
| 52 | * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher  | 
            ||
| 53 | *  | 
            ||
| 54 | * @return \eZ\Publish\API\Repository\Values\ValueObject  | 
            ||
| 55 | */  | 
            ||
| 56 | View Code Duplication | public function parse(array $data, ParsingDispatcher $parsingDispatcher)  | 
            |
| 78 | |||
| 79 | /**  | 
            ||
| 80 | * @return \eZ\Publish\API\Repository\Values\User\Limitation  | 
            ||
| 81 | */  | 
            ||
| 82 | protected function buildLimitation()  | 
            ||
| 86 | |||
| 87 | /**  | 
            ||
| 88 | * @param $limitationValue  | 
            ||
| 89 | *  | 
            ||
| 90 | * @return false|mixed  | 
            ||
| 91 | */  | 
            ||
| 92 | protected function parseIdFromHref($limitationValue)  | 
            ||
| 99 | }  | 
            ||
| 100 |