| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Acquia\LiftClient\Entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Acquia\LiftClient\Exception\LiftSdkException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | class Probability extends \ArrayObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     use EntityTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |    * @param array $array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |   public function __construct(array $array = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |       parent::__construct($array); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |    * Sets the 'id' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |    * @param string $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |    * @throws \Acquia\LiftClient\Exception\LiftSdkException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |    * @return \Acquia\LiftClient\Entity\Probability | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |   public function setContentId($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |       if (!is_string($contentId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |           throw new LiftSdkException('Argument must be an instance of string.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |       $this['id'] = $contentId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |       return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |    * Gets the 'id' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |    * @return string The Identifier of the Content Identifier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |   public function getContentId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |       return $this->getEntityValue('id', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |    * @param string $contentConnectorId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |    * @throws \Acquia\LiftClient\Exception\LiftSdkException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |    * @return \Acquia\LiftClient\Entity\Probability | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 54 |  |  |    */ | 
            
                                                                        
                            
            
                                                                    
                                                                                                        
            
            
                | 55 |  | View Code Duplication |   public function setContentConnectorId($contentConnectorId = 'content_hub') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |   { | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |       if (!is_string($contentConnectorId)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |           throw new LiftSdkException('Argument must be an instance of string.'); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |       } | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |       $this['content_connector_id'] = $contentConnectorId; | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |       return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |    * Gets the 'content_connector_id' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |    * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |   public function getContentConnectorId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |       return $this->getEntityValue('content_connector_id', 'content_hub'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |    * Sets the 'content_view_id' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |    * @param string $contentViewId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |    * @throws \Acquia\LiftClient\Exception\LiftSdkException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |    * @return \Acquia\LiftClient\Entity\Probability | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |   public function setContentViewId($contentViewId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |       if (!is_string($contentViewId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |           throw new LiftSdkException('Argument must be an instance of string.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |       $this['content_view_id'] = $contentViewId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |       return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |    * Gets the 'content_view_id' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |    * @return string The Content View Mode Identifier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |   public function getContentViewId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |       return $this->getEntityValue('content_view_id', ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |    * Sets the 'fraction' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |    * @param int|float $fraction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |    * @throws \Acquia\LiftClient\Exception\LiftSdkException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |    * @return \Acquia\LiftClient\Entity\Probability | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |   public function setFraction($fraction) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |       if (!is_numeric($fraction)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |           throw new LiftSdkException('Argument must be an instance of any numeric type (int|float).'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |       if ($fraction > 1 || $fraction < 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |           throw new LiftSdkException('Argument must be between 0 and 1 or those values themselves.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |       $this['fraction'] = $fraction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |       return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |    * Gets the 'fraction' parameter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |    * @return int|float The fraction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |   public function getFraction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |   { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |       return $this->getEntityValue('fraction', 0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |   } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 135 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 136 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.