| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Created by PhpStorm. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * User: Administrador | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Date: 16/10/2017 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Time: 04:23 PM. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace Greenter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Greenter\Builder\BuilderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Greenter\Factory\FeFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Greenter\Model\DocumentInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Greenter\Model\Summary\Summary; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Greenter\Model\Voided\Reversion; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Greenter\Model\Voided\Voided; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Greenter\Services\SenderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Greenter\Validator\ErrorCodeProviderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Greenter\Ws\Services\BillSender; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Greenter\Ws\Services\ExtService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Greenter\Ws\Services\SoapClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Greenter\Ws\Services\SummarySender; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Greenter\XMLSecLibs\Sunat\SignedXml; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * Sistema de Emision del Contribuyente. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * Class See | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | class See | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @var FeFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     private $factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @var SoapClient | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     private $wsClient; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     private $builders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     private $summarys; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @var SignedXml | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     private $signer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @var ErrorCodeProviderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     private $codeProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * Twig Render Options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     private $options = ['autoescape' => false]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * See constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 30 |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 30 |  |         $this->factory = new FeFactory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 30 |  |         $this->wsClient = new SoapClient(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 30 |  |         $this->signer = new SignedXml(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 30 |  |         $this->builders = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 30 |  |             Model\Sale\Invoice::class => Xml\Builder\InvoiceBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 30 |  |             Model\Sale\Note::class => Xml\Builder\NoteBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 30 |  |             Model\Summary\Summary::class => Xml\Builder\SummaryBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 30 |  |             Model\Voided\Voided::class => Xml\Builder\VoidedBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 30 |  |             Model\Despatch\Despatch::class => Xml\Builder\DespatchBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 30 |  |             Model\Retention\Retention::class => Xml\Builder\RetentionBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 30 |  |             Model\Perception\Perception::class => Xml\Builder\PerceptionBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 30 |  |             Model\Voided\Reversion::class => Xml\Builder\VoidedBuilder::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 30 |  |         $this->summarys = [Summary::class, Summary::class, Voided::class, Reversion::class]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 30 |  |         $this->factory->setSigner($this->signer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 30 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * Set Xml Builder Options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @param array $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 30 |  |     public function setBuilderOptions(array $options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 30 |  |         $this->options = array_merge($this->options, $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 30 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @param string $directory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 18 |  |     public function setCachePath($directory) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 18 |  |         $this->options['cache'] = $directory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 18 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param string $certificate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 30 |  |     public function setCertificate($certificate) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 30 |  |         $this->signer->setCertificate($certificate); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 30 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @param string $user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @param string $password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 30 |  |     public function setCredentials($user, $password) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 30 |  |         $this->wsClient->setCredentials($user, $password); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 30 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * @param string $service | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 30 |  |     public function setService($service) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 30 |  |         $this->wsClient->setService($service); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 30 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * Set error code provider. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @param ErrorCodeProviderInterface $codeProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 18 |  |     public function setCodeProvider($codeProvider) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 18 |  |         $this->codeProvider = $codeProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 18 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * Get signed xml from document. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @param DocumentInterface $document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 | 10 |  |     public function getXmlSigned(DocumentInterface $document) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 10 |  |         $classDoc = get_class($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 10 |  |         return $this->factory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 | 10 |  |             ->setBuilder($this->getBuilder($classDoc)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 10 |  |             ->getXmlSigned($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * Envia documento. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * @param DocumentInterface $document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * @return Model\Response\BaseResult | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 167 | 18 | View Code Duplication |     public function send(DocumentInterface $document) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 | 18 |  |         $classDoc = get_class($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 18 |  |         $this->factory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 18 |  |             ->setBuilder($this->getBuilder($classDoc)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 18 |  |             ->setSender($this->getSender($classDoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 18 |  |         return $this->factory->send($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	// Solicitar CDR desde un XML ya generado. by thefantas | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 178 |  | View Code Duplication |     public function sendForce(DocumentInterface $document, $dir_xml) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         $classDoc = get_class($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $this->factory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             ->setBuilder($this->getBuilder($classDoc)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             ->setSender($this->getSender($classDoc)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         return $this->factory->send($document, $dir_xml); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 187 |  |  | 	// Generar solo XML. by thefantas | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |     public function genXML(DocumentInterface $document) | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |         $classDoc = get_class($document); | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  |         $this->factory | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  |             ->setBuilder($this->getBuilder($classDoc)); | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  |         return $this->factory->genXML($document); | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * @param $ticket | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @return Model\Response\StatusResult | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 2 |  |     public function getStatus($ticket) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 2 |  |         $sender = new ExtService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 2 |  |         $sender->setClient($this->wsClient); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 | 2 |  |         return $sender->getStatus($ticket); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * @return FeFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 | 6 |  |     public function getFactory() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 | 6 |  |         return $this->factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @param string $class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * @return BuilderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 28 |  |     private function getBuilder($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 | 28 |  |         $builder = $this->builders[$class]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 | 28 |  |         return new $builder($this->options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * @param string $class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * @return SenderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 18 |  |     private function getSender($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 | 18 |  |         $sender = in_array($class, $this->summarys) ? new SummarySender() : new BillSender(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 | 18 |  |         $sender->setClient($this->wsClient); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 18 |  |         if ($this->codeProvider) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 | 10 |  |             $sender->setCodeProvider($this->codeProvider); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 10 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 | 18 |  |         return $sender; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 245 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 246 |  |  |  | 
            
                        
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.