| Total Complexity | 13 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | abstract class Correios |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var \stdClass |
||
| 13 | */ |
||
| 14 | private $ws = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var ConfigContract |
||
| 18 | */ |
||
| 19 | private $config = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var Soap |
||
| 23 | */ |
||
| 24 | private $soap = null; |
||
| 25 | |||
| 26 | public function __construct(ConfigContract $config = null, $type = 'curl') |
||
| 27 | { |
||
| 28 | $this->config = $config ?: new Testing(); |
||
| 29 | $this->makeSoap($type); |
||
| 30 | $webservices = realpath(CORREIOS_PHP_BASE) . '/storage/webservices.json'; |
||
| 31 | $this->setWs(json_decode(file_get_contents($webservices))); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param \stdClass $ws |
||
| 36 | * |
||
| 37 | * @return $this |
||
| 38 | */ |
||
| 39 | protected function setWs(\stdClass $ws) |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param null $key |
||
|
|
|||
| 47 | * |
||
| 48 | * @return \stdClass |
||
| 49 | */ |
||
| 50 | protected function getWs($key = null) |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param $type |
||
| 59 | * |
||
| 60 | * @return Soap |
||
| 61 | * @throws InvalidSoapException |
||
| 62 | */ |
||
| 63 | private function makeSoap($type) |
||
| 64 | { |
||
| 65 | $soapClass = '\\Eduardokum\\CorreiosPhp\\Soap\\Soap' . ucfirst(strtolower($type)); |
||
| 66 | |||
| 67 | if (class_exists($soapClass) && !empty(trim($type))) { |
||
| 68 | $this->soap = new $soapClass(); |
||
| 69 | return $this->soap; |
||
| 70 | } |
||
| 71 | |||
| 72 | throw new InvalidSoapException("The type '$type' is not acceptable"); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return mixed |
||
| 77 | */ |
||
| 78 | protected function url() |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return ConfigContract |
||
| 86 | */ |
||
| 87 | public function getConfig() |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @return Soap |
||
| 94 | */ |
||
| 95 | public function getSoap() |
||
| 98 | } |
||
| 99 | } |
||
| 100 |