| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * The MIT License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright 2016 julien. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * in the Software without restriction, including without limitation the rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * furnished to do so, subject to the following conditions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * The above copyright notice and this permission notice shall be included in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * all copies or substantial portions of the Software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * THE SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace PHPHealth\CDA\RIM\Role; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use PHPHealth\CDA\DataType\Collection\Set; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use PHPHealth\CDA\RIM\Entity\Person; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use PHPHealth\CDA\DataType\Code\CodedWithEquivalents; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use PHPHealth\CDA\DataType\Identifier\InstanceIdentifier; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use PHPHealth\CDA\Elements\Id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @author julien | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | class AssignedAuthor extends Role | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @var Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     protected $ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var CodedWithEquivalents | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected $code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * @var Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     protected $addrs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @var Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     protected $telecoms; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @var Person | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     protected $author; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @param Person $author | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @param Set $ids | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * @param CodedWithEquivalents $code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      * @param Set $addrs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * @param Set $telecoms | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         Person $author,  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         Set $ids, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         CodedWithEquivalents $code = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         Set $addrs = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         Set $telecoms = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $this->setAuthor($author); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->setIds($ids); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         if (null !== $code) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             $this->setCode($code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         if (null !== $addrs) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             $this->setAddrs($addrs); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         if (null !== $telecoms) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $this->setTelecoms($telecoms); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     public function getIds(): Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         return $this->ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     public function getCode(): CodedWithEquivalents | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         return $this->code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     public function getAddrs(): Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         return $this->addrs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     public function getTelecoms(): Set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         return $this->telecoms; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function getAuthor(): Person | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         return $this->author; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |     public function setIds(Set $ids) | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |         $ids->checkContainsOrThrow(InstanceIdentifier::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |         $this->ids = $ids; | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |         return $this; | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function setCode(CodedWithEquivalents $code) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $this->code = $code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     public function setAddrs(Set $addrs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $this->addrs = $addrs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     public function setTelecoms(Set $telecoms) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         $this->telecoms = $telecoms; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     public function setAuthor(Person $author) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         $this->author = $author; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     protected function getElementTag(): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         return 'assignedAuthor'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     public function getClassCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         return 'ASSIGNED'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 170 |  | View Code Duplication |     public function toDOMElement(\DOMDocument $doc): \DOMElement | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         $el = $this->createElement($doc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         foreach ($this->ids->get() as $ii) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             $el->appendChild((new Id($ii))->toDOMElement($doc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $el->appendChild($this->author->toDOMElement($doc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         return $el; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 182 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 183 |  |  |  | 
            
                        
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.