| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 100 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 7 | class Peer |
||
| 8 | { |
||
| 9 | public static $is_initialized = false; |
||
| 10 | |||
| 11 | public static function initOnce() { |
||
| 12 | $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
||
| 13 | |||
| 14 | if (static::$is_initialized == true) { |
||
| 15 | return; |
||
| 16 | } |
||
| 17 | \GPBMetadata\Peer\Proposal::initOnce(); |
||
| 18 | \GPBMetadata\Peer\ProposalResponse::initOnce(); |
||
| 19 | $pool->internalAddGeneratedFile(hex2bin( |
||
| 20 | "0ad9020a0f706565722f706565722e70726f746f120670726f746f731a1c" . |
||
| 21 | "706565722f70726f706f73616c5f726573706f6e73652e70726f746f2216" . |
||
| 22 | "0a06506565724944120c0a046e616d65180120012809223b0a0c50656572" . |
||
| 23 | "456e64706f696e74121a0a02696418012001280b320e2e70726f746f732e" . |
||
| 24 | "506565724944120f0a076164647265737318022001280932510a08456e64" . |
||
| 25 | "6f7273657212450a0f50726f6365737350726f706f73616c12162e70726f" . |
||
| 26 | "746f732e5369676e656450726f706f73616c1a182e70726f746f732e5072" . |
||
| 27 | "6f706f73616c526573706f6e7365220042700a226f72672e68797065726c" . |
||
| 28 | "65646765722e6661627269632e70726f746f732e706565725a2967697468" . |
||
| 29 | "75622e636f6d2f68797065726c65646765722f6661627269632f70726f74" . |
||
| 30 | "6f732f70656572ca021e48797065726c65646765725c4661627269635c50" . |
||
| 31 | "726f746f735c50656572620670726f746f33" |
||
| 32 | )); |
||
| 33 | |||
| 34 | static::$is_initialized = true; |
||
| 35 | } |
||
| 38 |