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 |
||
| 9 | class Jetpack_Sync_JSON_Deflate_Array_Codec implements iJetpack_Sync_Codec { |
||
| 10 | const CODEC_NAME = "deflate-json-array"; |
||
| 11 | |||
| 12 | public function name() { |
||
| 15 | |||
| 16 | public function encode( $object ) { |
||
| 19 | |||
| 20 | public function decode( $input ) { |
||
| 23 | |||
| 24 | // @see https://gist.github.com/muhqu/820694 |
||
| 25 | private function json_serialize( $any ) { |
||
| 28 | |||
| 29 | private function json_unserialize( $str ) { |
||
| 32 | |||
| 33 | private function json_wrap( $any, $seen_nodes = array() ) { |
||
| 55 | |||
| 56 | private function json_unwrap( $any ) { |
||
| 73 | } |