diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68c92c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +/tests/Unit/Seanautica/ \ No newline at end of file diff --git a/README.md b/README.md index 8f9b02f..8695e98 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,28 @@ Com a biblioteca o desenvolvedor utiliza uma interface simples, setando alguns p Todo o processo de integração é feito nos bastidores e o preço do frete e tempo de entrega é devolvido ao desenvolvedor para poder utilizar em sua aplicação sem o menor esforço. O desenvolvedor pode calcular, de uma única vez, o preço do frete para os diversos serviços oferecidos pelo Correios, eliminando várias chamadas ao serviço e diminuindo o tempo de espera do cliente. +Instalar +-------- + +Instalação via [Composer](http://www.getcomposer.org) + + php composer.phar require imastersdev/correios + Como Usar ? ----------- > A biblioteca pode fazer o cálculo de 1 serviço: prdt(); $prdt->setNVlAltura( 10 ); $prdt->setNVlComprimento( 20 ); $prdt->setNVlLargura( 20 ); - $prdt->setNCdFormato( ECTFormatos::FORMATO_CAIXA_PACOTE ); - $prdt->setNCdServico( ECTServicos::PAC ); //calculando apenas PAC + $prdt->setNCdFormato( \Imasters\Php\Ect\Prdt\ECTFormatos::FORMATO_CAIXA_PACOTE ); + $prdt->setNCdServico( \Imasters\Php\Ect\Prdt\ECTServicos::PAC ); //calculando apenas PAC $prdt->setSCepOrigem( '09641030' ); $prdt->setSCepDestino( '27511300' ); $prdt->setNVlPeso( 10 ); @@ -32,19 +39,21 @@ Como Usar ? > Ou de vários ao mesmo tempo, eliminando-se assim o tempo de espera do cliente: prdt(); $prdt->setNVlAltura( 10 ); $prdt->setNVlComprimento( 20 ); $prdt->setNVlLargura( 20 ); - $prdt->setNCdFormato( ECTFormatos::FORMATO_CAIXA_PACOTE ); - $prdt->setNCdServico( implode( ',' , array( ECTServicos::PAC , ECTServicos::SEDEX ) ) ); + $prdt->setNCdFormato( \Imasters\Php\Ect\Prdt\ECTFormatos::FORMATO_CAIXA_PACOTE ); + $prdt->setNCdServico( implode( ',' , array( \Imasters\Php\Ect\Prdt\ECTServicos::PAC , \Imasters\Php\Ect\Prdt\ECTServicos::SEDEX ) ) ); $prdt->setSCepOrigem( '09641030' ); $prdt->setSCepDestino( '27511300' ); $prdt->setNVlPeso( 10 ); foreach ( $prdt->call() as $servico ) { printf( "O preço do frete do correios para o serviço %d é R$ %.02f\n" , $servico->Codigo , $servico->Valor ); - } \ No newline at end of file + } + +http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=14335794&sDsSenha=70994140&sCepOrigem=30160041&sCepDestino=30180100&nVlPeso=1&nCdFormato=1&nVlComprimento=20&nVlAltura=10&nVlLargura=20&sCdMaoPropria=n&nVlValorDeclarado=0&sCdAvisoRecebimento=n&nCdServico=41106&nVlDiametro=0&StrRetorno=xml&nIndicaCalculo=3 \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a49f37b --- /dev/null +++ b/composer.json @@ -0,0 +1,34 @@ +{ + "name": "imastersdev/correios", + "description": "Webservice integration with Brazillian Correios Service", + "version": "1.0.0", + "keywords": ["correios", "webservice"], + "license": "MIT", + "authors": [ + { + "name": "iMasters Dev", + "homepage": "http://imasters.com.br/noticia/imasters-lanca-novo-pacote-de-integracao-com-os-correios/", + "role": "developer" + }, + { + "name": "Glauber Portella", + "email": "glauberportella@gmail.com", + "role": "developer" + } + ], + "support": { + "email": "glauberportella@gmail.com" + }, + "autoload": { + "psr-4": { + "Imasters\\": "imasters", + "D4w\\": "d4w" + } + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.4.*" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..0ed4ad0 --- /dev/null +++ b/composer.lock @@ -0,0 +1,863 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "f54a0960e69bfbafea045ee35e15fb49", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.15", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/34cc484af1ca149188d0d9e91412191e398e0b67", + "reference": "34cc484af1ca149188d0d9e91412191e398e0b67", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-01-24 10:06:35" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/db32c18eba00b121c145575fcbcd4d4d24e6db74", + "reference": "db32c18eba00b121c145575fcbcd4d4d24e6db74", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-01-17 09:51:32" + }, + { + "name": "phpunit/phpunit", + "version": "4.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2e8580deebb7d1ac92ac878595e6bffe01069c2a", + "reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.1", + "sebastian/exporter": "~1.1", + "sebastian/global-state": "~1.0", + "sebastian/recursion-context": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2015-01-27 16:06:15" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "c63d2367247365f688544f0d500af90a11a44c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.1", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2014-10-03 05:12:11" + }, + { + "name": "sebastian/comparator", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dd8869519a225f7f2b9eb663e225298fade819e", + "reference": "1dd8869519a225f7f2b9eb663e225298fade819e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-01-29 16:28:08" + }, + { + "name": "sebastian/diff", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2014-08-15 10:29:00" + }, + { + "name": "sebastian/environment", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e6c71d918088c251b181ba8b3088af4ac336dd7", + "reference": "6e6c71d918088c251b181ba8b3088af4ac336dd7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-10-25 08:00:45" + }, + { + "name": "sebastian/exporter", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "84839970d05254c73cde183a721c7af13aede943" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/84839970d05254c73cde183a721c7af13aede943", + "reference": "84839970d05254c73cde183a721c7af13aede943", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-01-27 07:23:06" + }, + { + "name": "sebastian/global-state", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2014-10-06 09:23:50" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/3989662bbb30a29d20d9faa04a846af79b276252", + "reference": "3989662bbb30a29d20d9faa04a846af79b276252", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-01-24 09:48:32" + }, + { + "name": "sebastian/version", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/a77d9123f8e809db3fbdea15038c27a95da4058b", + "reference": "a77d9123f8e809db3fbdea15038c27a95da4058b", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-12-15 14:25:24" + }, + { + "name": "symfony/yaml", + "version": "v2.6.3", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "82462a90848a52c2533aa6b598b107d68076b018" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/82462a90848a52c2533aa6b598b107d68076b018", + "reference": "82462a90848a52c2533aa6b598b107d68076b018", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2015-01-03 15:33:07" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [] +} diff --git a/d4w/Ect/Cep/Faixas.php b/d4w/Ect/Cep/Faixas.php new file mode 100644 index 0000000..ca56d3b --- /dev/null +++ b/d4w/Ect/Cep/Faixas.php @@ -0,0 +1,112 @@ + array('01000','19999'), + 'rj' => array('20000','28999'), + 'es' => array('29000','29999'), + 'mg' => array('30000','39999'), + 'ba' => array('40000','48999'), + 'se' => array('49000','49999'), + 'pe' => array('50000','56999'), + 'al' => array('57000','57999'), + 'pb' => array('58000','58999'), + 'rn' => array('59000','59999'), + 'ce' => array('60000','63999'), + 'pi' => array('64000','64999'), + 'ma' => array('65000','65999'), + 'pa' => array('66000','68899'), + 'ap' => array('68900','68999'), + 'am-1' => array('69000','69299'), + 'am-2' => array('69400','69899'), + 'rr' => array('69300','69399'), + 'ac' => array('69900','69999'), + 'df-1' => array('70000','72799'), + 'df-2' => array('73000','73699'), + 'go-1' => array('72800','72999'), + 'go-2' => array('73700','76799'), + 'to' => array('77000','77999'), + 'mt' => array('78000','78899'), + 'ro' => array('78900','78999'), + 'ms' => array('79000','79999'), + 'pr' => array('80000','87999'), + 'sc' => array('88000','89999'), + 'rs' => array('90000','99999'), + ); + + protected static $ceps_capitais = array( + 'ac' => array('capital' => 'Rio Branco', 'cep_ini' => '69900', 'cep_fim' => '69920'), + 'al' => array('capital' => 'Maceió', 'cep_ini' => '57000', 'cep_fim' => '57099'), + 'am' => array('capital' => 'Manaus', 'cep_ini' => '69000', 'cep_fim' => '69099'), + 'ap' => array('capital' => 'Macapá', 'cep_ini' => '68900', 'cep_fim' => '68914'), + 'ba' => array('capital' => 'Salvador', 'cep_ini' => '40000', 'cep_fim' => '41999'), + 'ce' => array('capital' => 'Fortaleza', 'cep_ini' => '60000', 'cep_fim' => '60999'), + 'df' => array('capital' => 'Brasília', 'cep_ini' => '70700', 'cep_fim' => '70999'), + 'es' => array('capital' => 'Vitória', 'cep_ini' => '29000', 'cep_fim' => '29099'), + 'go' => array('capital' => 'Goiânia', 'cep_ini' => '74000', 'cep_fim' => '74894'), + 'ma' => array('capital' => 'São Luís', 'cep_ini' => '65000', 'cep_fim' => '65099'), + 'mg' => array('capital' => 'Belo Horizonte', 'cep_ini' => '30000', 'cep_fim' => '31999'), + 'ms' => array('capital' => 'Campo Grande', 'cep_ini' => '79000', 'cep_fim' => '79129'), + 'mt' => array('capital' => 'Cuiabá', 'cep_ini' => '78000', 'cep_fim' => '78109'), + 'pa' => array('capital' => 'Belém', 'cep_ini' => '66000', 'cep_fim' => '66999'), + 'pb' => array('capital' => 'João Pessoa', 'cep_ini' => '58000', 'cep_fim' => '58099'), + 'pe' => array('capital' => 'Recife', 'cep_ini' => '50000', 'cep_fim' => '52999'), + 'pi' => array('capital' => 'Teresina', 'cep_ini' => '64000', 'cep_fim' => '64099'), + 'pr' => array('capital' => 'Curitiba', 'cep_ini' => '80000', 'cep_fim' => '82999'), + 'rj' => array('capital' => 'Rio de Janeiro', 'cep_ini' => '20000', 'cep_fim' => '23799'), + 'rn' => array('capital' => 'Natal', 'cep_ini' => '59000', 'cep_fim' => '59099'), + 'ro' => array('capital' => 'Porto Velho', 'cep_ini' => '78900', 'cep_fim' => '78930'), + 'rr' => array('capital' => 'Boa Vista', 'cep_ini' => '69300', 'cep_fim' => '69339'), + 'rs' => array('capital' => 'Porto Alegre', 'cep_ini' => '90000', 'cep_fim' => '91999'), + 'sc' => array('capital' => 'Florianópolis', 'cep_ini' => '88000', 'cep_fim' => '82999'), + 'se' => array('capital' => 'Aracaju', 'cep_ini' => '49000', 'cep_fim' => '49099'), + 'sp' => array('capital' => 'São Paulo', 'cep_ini' => '01000', 'cep_fim' => '05999'), + 'to' => array('capital' => 'Palmas', 'cep_ini' => '77000', 'cep_fim' => '77270'), + ); + + /** + * Retorna o estado de um cep + * @param string $cep CEP + * @return array Retorna array onde index 0 é o estado e caso seja de Brasília index 1 é igual a 'df' + */ + public static function getEstado($cep) + { + $prefixo_int = self::prefixo($cep); + + foreach (self::$ceps as $estado => $espectro) { + $ini = intval($espectro[0]); + $fim = intval($espectro[1]); + if ($prefixo_int >= $ini && $prefixo_int <= $fim) { + return substr($estado, 0, 2); + } + } + + return false; + } + + public static function isCapital($cep) + { + $prefixo = self::prefixo($cep); + foreach (self::$ceps_capitais as $estado => $val) { + $ini = intval($val['cep_ini']); + $fim = intval($val['cep_fim']); + if ($prefixo >= $ini && $prefixo <= $fim) { + return true; + } + } + return false; + } + + protected static function prefixo($cep) + { + $cep = preg_replace('/[^0-9]/', '', $cep); + $prefixo = substr($cep, 0, 5); + return intval($prefixo); + } +} \ No newline at end of file diff --git a/d4w/Ect/Doc/Manual-de-Implementacao-do-Calculo-Remoto-de-Precos-e-Prazos.pdf b/d4w/Ect/Doc/Manual-de-Implementacao-do-Calculo-Remoto-de-Precos-e-Prazos.pdf new file mode 100644 index 0000000..6ba2f93 Binary files /dev/null and b/d4w/Ect/Doc/Manual-de-Implementacao-do-Calculo-Remoto-de-Precos-e-Prazos.pdf differ diff --git a/d4w/Ect/Doc/Manual_de_Implementacao_do_Web_Service_SIGEPWEB_Logistica_Reversa.pdf b/d4w/Ect/Doc/Manual_de_Implementacao_do_Web_Service_SIGEPWEB_Logistica_Reversa.pdf new file mode 100644 index 0000000..f1cc303 Binary files /dev/null and b/d4w/Ect/Doc/Manual_de_Implementacao_do_Web_Service_SIGEPWEB_Logistica_Reversa.pdf differ diff --git a/d4w/Ect/Tabela.php b/d4w/Ect/Tabela.php new file mode 100644 index 0000000..6d2827b --- /dev/null +++ b/d4w/Ect/Tabela.php @@ -0,0 +1,97 @@ +cep_origem = $cep_origem; + + if (file_exists($csv)) { + $this->load($csv); + } + } + + /** + * Carrega tarifas do arquivo csv no formato requerido + * @param string $csv Caminho do arquivo csv + * @throws \RuntimeException Se nao puder carregar o arquivo csv + * @return void + */ + public function load($csv) + { + $fp = fopen($csv, 'r'); + if (!$fp) + thrown new \RuntimeException('Não foi possível abrir o arquivo informado "' . $csv . '".' ); + while (($data = fgetcsv($fp, 0, Tabela::CSV_DELIMITER, Tabela::CSV_ENCLOSURE, Tabela::CSV_ESCAPE)) !== FALSE) { + if (!$this->estado_origem) + $this->estado_origem = $data[Tabela::CSV_ESTADO]; + + $tipo = $data[Tabela::CSV_TIPO]; + + $this->peso_ini[$tipo][] = $data[Tabela::CSV_FAIXA_PESO_INI]; + $this->peso_fim[$tipo][] = $data[Tabela::CSV_FAIXA_PESO_FIM]; + $this->local[$tipo][] = $data[Tabela::CSV_LOCAL]; + $this->estadual[$tipo][] = $data[Tabela::CSV_ESTADUAL]; + $this->faixa1[$tipo][] = $data[Tabela::CSV_F1]; + $this->faixa2[$tipo][] = $data[Tabela::CSV_F2]; + $this->faixa3[$tipo][] = $data[Tabela::CSV_F3]; + $this->faixa4[$tipo][] = $data[Tabela::CSV_F4]; + $this->faixa5[$tipo][] = $data[Tabela::CSV_F5]; + $this->faixa6[$tipo][] = $data[Tabela::CSV_F6]; + } + if ($fp) + fclose($fp); + } + + /** + * Calcular frete conforme tabela carregada + * @param string $cep_destino CEP de destino da encomenda + * @param float $peso Peso em kg + * @return float + */ + public function calculate($cep_destino, $peso) + { + $estado_destino = \D4w\Ect\Cep\Faixas::getEstado($cep_destino); + $is_local = $this->estado_origem === $estado_destino; + $is_capital = \D4w\Ect\Cep\Faixas::isCapital($this->cep_origem) && \D4w\Ect\Cep\Faixas::isCapital($cep_destino); + + $peso_gramas = $peso / 1000; + + if ($is_capital) { + // capital - capital + if ($is_local) { + foreach ($this->peso_ini['capital'] as $k => $peso_ini) { + $peso_fim = $this->peso_fim['capital'][$k]; + if ($peso_gramas >= $peso_ini && $peso_gramas <= $peso_fim) { + return $this->local['capital'][$k]; + } + } + } else { + + } + } else { + // capital - interior, interior - interior, interior - capital + + } + } +} \ No newline at end of file diff --git a/exemplo.php b/exemplo.php index eea4077..99b15b3 100644 --- a/exemplo.php +++ b/exemplo.php @@ -1,13 +1,13 @@ prdt(); $prdt->setNVlAltura( 10 ); $prdt->setNVlComprimento( 20 ); $prdt->setNVlLargura( 20 ); -$prdt->setNCdFormato( ECTFormatos::FORMATO_CAIXA_PACOTE ); -$prdt->setNCdServico( ECTServicos::PAC ); +$prdt->setNCdFormato( \Imasters\Php\Ect\Prdt\ECTFormatos::FORMATO_CAIXA_PACOTE ); +$prdt->setNCdServico( \Imasters\Php\Ect\Prdt\ECTServicos::PAC ); $prdt->setSCepOrigem( '09641030' ); $prdt->setSCepDestino( '27511300' ); $prdt->setNVlPeso( 10 ); diff --git a/com/imasters/php/ect/ECT.php b/imasters/Php/Ect/ECT.php similarity index 83% rename from com/imasters/php/ect/ECT.php rename to imasters/Php/Ect/ECT.php index c87fb45..04600ee 100644 --- a/com/imasters/php/ect/ECT.php +++ b/imasters/Php/Ect/ECT.php @@ -5,9 +5,12 @@ * @package com.imasters.php.ect */ -require_once 'com/imasters/php/http/HTTPConnection.php'; -require_once 'com/imasters/php/http/HTTPCookieManager.php'; -require_once 'com/imasters/php/ect/prdt/Prdt.php'; +namespace Imasters\Php\Ect; + +use \Imasters\Php\Http\HTTPConnection; +use \Imasters\Php\Http\HTTPCookieManager; + +use \Imasters\Php\Ect\Prdt\Prdt; /** * @brief Interface para APIs dos Correios (ECT) diff --git a/com/imasters/php/ect/EctAPI.php b/imasters/Php/Ect/EctAPI.php similarity index 87% rename from com/imasters/php/ect/EctAPI.php rename to imasters/Php/Ect/EctAPI.php index dda0e47..f4f719d 100644 --- a/com/imasters/php/ect/EctAPI.php +++ b/imasters/Php/Ect/EctAPI.php @@ -5,8 +5,7 @@ * @package com.imasters.php.ect */ -require_once 'com/imasters/php/http/HTTPConnection.php'; -require_once 'com/imasters/php/http/HTTPCookieManager.php'; +namespace Imasters\Php\Ect; /** * @brief Interface para definição de uma API do Correios diff --git a/com/imasters/php/ect/prdt/ECTFormatos.php b/imasters/Php/Ect/Prdt/ECTFormatos.php similarity index 92% rename from com/imasters/php/ect/prdt/ECTFormatos.php rename to imasters/Php/Ect/Prdt/ECTFormatos.php index e983a2a..21aaade 100644 --- a/com/imasters/php/ect/prdt/ECTFormatos.php +++ b/imasters/Php/Ect/Prdt/ECTFormatos.php @@ -5,6 +5,8 @@ * @package com.imasters.php.ect.prdt */ +namespace Imasters\Php\Ect\Prdt; + /** * @brief Tipos de formato de encomenda * @author João Batista Neto diff --git a/com/imasters/php/ect/prdt/ECTServico.php b/imasters/Php/Ect/Prdt/ECTServico.php similarity index 97% rename from com/imasters/php/ect/prdt/ECTServico.php rename to imasters/Php/Ect/Prdt/ECTServico.php index e307306..11b55b6 100644 --- a/com/imasters/php/ect/prdt/ECTServico.php +++ b/imasters/Php/Ect/Prdt/ECTServico.php @@ -5,6 +5,8 @@ * @package com.imasters.php.ect.prdt */ +namespace Imasters\Php\Ect\Prdt; + /** * @brief Informações sobre preço e prazo cobrados para um serviço do Correios * @author João Batista Neto diff --git a/com/imasters/php/ect/prdt/ECTServicos.php b/imasters/Php/Ect/Prdt/ECTServicos.php similarity index 96% rename from com/imasters/php/ect/prdt/ECTServicos.php rename to imasters/Php/Ect/Prdt/ECTServicos.php index d895cc6..bb83085 100644 --- a/com/imasters/php/ect/prdt/ECTServicos.php +++ b/imasters/Php/Ect/Prdt/ECTServicos.php @@ -5,6 +5,8 @@ * @package com.imasters.php.ect.prdt */ +namespace Imasters\Php\Ect\Prdt; + /** * @brief Tipos de serviços oferecidos pelo Correios * @author João Batista Neto diff --git a/com/imasters/php/ect/prdt/Prdt.php b/imasters/Php/Ect/Prdt/Prdt.php similarity index 97% rename from com/imasters/php/ect/prdt/Prdt.php rename to imasters/Php/Ect/Prdt/Prdt.php index a54891b..4b00f5e 100644 --- a/com/imasters/php/ect/prdt/Prdt.php +++ b/imasters/Php/Ect/Prdt/Prdt.php @@ -5,10 +5,17 @@ * @package com.imasters.php.ect.prdt */ -require_once 'com/imasters/php/ect/prdt/ECTFormatos.php'; -require_once 'com/imasters/php/ect/prdt/ECTServicos.php'; -require_once 'com/imasters/php/ect/EctAPI.php'; -require_once 'com/imasters/php/ect/prdt/ECTServico.php'; +namespace Imasters\Php\Ect\Prdt; + +use \Imasters\Php\Ect\ECT; +use \Imasters\Php\Ect\EctAPI; +use \Imasters\Php\Ect\Prdt\ECTFormatos; +use \Imasters\Php\Ect\Prdt\ECTServicos; +use \Imasters\Php\Ect\Prdt\ECTServico; + +use \ArrayIterator; +use \DOMDocument; +use \DOMXPath; /** * @brief Cálculo de preços e prazos de entrega de encomendas diff --git a/com/imasters/php/http/CURL.php b/imasters/Php/Http/CURL.php similarity index 98% rename from com/imasters/php/http/CURL.php rename to imasters/Php/Http/CURL.php index c1e4fa5..1fe3cff 100644 --- a/com/imasters/php/http/CURL.php +++ b/imasters/Php/Http/CURL.php @@ -5,8 +5,11 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/HTTPRequest.php'; -require_once 'com/imasters/php/http/HTTPResponse.php'; +namespace Imasters\Php\Http; + +use \InvalidArgumentException; +use \RuntimeException; +use \UnexpectedValueException; /** * @author João Batista Neto diff --git a/com/imasters/php/http/Cookie.php b/imasters/Php/Http/Cookie.php similarity index 98% rename from com/imasters/php/http/Cookie.php rename to imasters/Php/Http/Cookie.php index 3c8e0f0..016327b 100644 --- a/com/imasters/php/http/Cookie.php +++ b/imasters/Php/Http/Cookie.php @@ -5,6 +5,10 @@ * @package com.imasters.php.http */ +namespace Imasters\Php\Http; + +use \InvalidArgumentException; + /** * @author João Batista Neto * @brief Cookie HTTP diff --git a/com/imasters/php/http/CookieManager.php b/imasters/Php/Http/CookieManager.php similarity index 96% rename from com/imasters/php/http/CookieManager.php rename to imasters/Php/Http/CookieManager.php index d60cd74..de5b298 100644 --- a/com/imasters/php/http/CookieManager.php +++ b/imasters/Php/Http/CookieManager.php @@ -5,7 +5,9 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/Cookie.php'; +namespace Imasters\Php\Http; + +use \Serializable; /** * @author João Batista Neto diff --git a/com/imasters/php/http/HTTPAuthenticator.php b/imasters/Php/Http/HTTPAuthenticator.php similarity index 89% rename from com/imasters/php/http/HTTPAuthenticator.php rename to imasters/Php/Http/HTTPAuthenticator.php index 678265b..2e78b75 100644 --- a/com/imasters/php/http/HTTPAuthenticator.php +++ b/imasters/Php/Http/HTTPAuthenticator.php @@ -5,7 +5,7 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/HTTPRequest.php'; +namespace Imasters\Php\Http; /** * @author João Batista Neto diff --git a/com/imasters/php/http/HTTPConnection.php b/imasters/Php/Http/HTTPConnection.php similarity index 98% rename from com/imasters/php/http/HTTPConnection.php rename to imasters/Php/Http/HTTPConnection.php index 365a56a..dddf1a2 100644 --- a/com/imasters/php/http/HTTPConnection.php +++ b/imasters/Php/Http/HTTPConnection.php @@ -5,9 +5,10 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/HTTPAuthenticator.php'; -require_once 'com/imasters/php/http/HTTPRequestMethod.php'; -require_once 'com/imasters/php/http/CURL.php'; +namespace Imasters\Php\Http; + +use \InvalidArgumentException; +use \BadMethodCallException; /** * @author João Batista Neto diff --git a/com/imasters/php/http/HTTPCookieManager.php b/imasters/Php/Http/HTTPCookieManager.php similarity index 98% rename from com/imasters/php/http/HTTPCookieManager.php rename to imasters/Php/Http/HTTPCookieManager.php index 82bcfc3..c1bbf72 100644 --- a/com/imasters/php/http/HTTPCookieManager.php +++ b/imasters/Php/Http/HTTPCookieManager.php @@ -5,7 +5,9 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/CookieManager.php'; +namespace Imasters\Php\Http; + +use \RuntimeException; /** * @author João Batista Neto diff --git a/com/imasters/php/http/HTTPRequest.php b/imasters/Php/Http/HTTPRequest.php similarity index 93% rename from com/imasters/php/http/HTTPRequest.php rename to imasters/Php/Http/HTTPRequest.php index c7a1da9..9aed0e1 100644 --- a/com/imasters/php/http/HTTPRequest.php +++ b/imasters/Php/Http/HTTPRequest.php @@ -5,9 +5,7 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/HTTPConnection.php'; -require_once 'com/imasters/php/http/HTTPAuthenticator.php'; -require_once 'com/imasters/php/http/HTTPRequestMethod.php'; +namespace Imasters\Php\Http; /** * @author João Batista Neto diff --git a/com/imasters/php/http/HTTPRequestMethod.php b/imasters/Php/Http/HTTPRequestMethod.php similarity index 94% rename from com/imasters/php/http/HTTPRequestMethod.php rename to imasters/Php/Http/HTTPRequestMethod.php index 40ae551..e56ab46 100644 --- a/com/imasters/php/http/HTTPRequestMethod.php +++ b/imasters/Php/Http/HTTPRequestMethod.php @@ -5,6 +5,8 @@ * @package com.imasters.php.http */ +namespace Imasters\Php\Http; + /** * @author João Batista Neto * @brief Constantes para identificar o método de requisição HTTP diff --git a/com/imasters/php/http/HTTPResponse.php b/imasters/Php/Http/HTTPResponse.php similarity index 98% rename from com/imasters/php/http/HTTPResponse.php rename to imasters/Php/Http/HTTPResponse.php index ed15075..2c5a880 100644 --- a/com/imasters/php/http/HTTPResponse.php +++ b/imasters/Php/Http/HTTPResponse.php @@ -5,7 +5,7 @@ * @package com.imasters.php.http */ -require_once 'com/imasters/php/http/CookieManager.php'; +namespace Imasters\Php\Http; /** * @author João Batista Neto diff --git a/tests/Unit/CookieTest.php b/tests/Unit/CookieTest.php new file mode 100644 index 0000000..6b69321 --- /dev/null +++ b/tests/Unit/CookieTest.php @@ -0,0 +1,14 @@ +assertInstanceOf('\Imasters\Php\Ect\ECT', $ect); + + $prdt = $ect->prdt(); + $this->assertInstanceOf('\Imasters\Php\Ect\Prdt\Prdt', $prdt); + } +} \ No newline at end of file diff --git a/tests/Unit/D4w/Ect/Cep/FaixasTest.php b/tests/Unit/D4w/Ect/Cep/FaixasTest.php new file mode 100644 index 0000000..823c9ff --- /dev/null +++ b/tests/Unit/D4w/Ect/Cep/FaixasTest.php @@ -0,0 +1,83 @@ +assertEquals('01000800', $cep); + + $prefixo = substr($cep, 0, 5); + $this->assertEquals('01000', $prefixo); + + $prefixo_int = intval($prefixo); + $this->assertEquals(1000, $prefixo_int); + } + + public function testEstado() + { + // goias e distrito federal tem teste a parte + // + $this->assertEquals('ac', \D4w\Ect\Cep\Faixas::getEstado('69900-010')); + $this->assertEquals('al', \D4w\Ect\Cep\Faixas::getEstado('57010-060')); + $this->assertEquals('am', \D4w\Ect\Cep\Faixas::getEstado('69005-050')); + $this->assertEquals('ap', \D4w\Ect\Cep\Faixas::getEstado('68900-021')); + $this->assertEquals('ba', \D4w\Ect\Cep\Faixas::getEstado('40015-060')); + $this->assertEquals('ce', \D4w\Ect\Cep\Faixas::getEstado('60010-122')); + $this->assertEquals('es', \D4w\Ect\Cep\Faixas::getEstado('29010-060')); + $this->assertEquals('ma', \D4w\Ect\Cep\Faixas::getEstado('65010-230')); + $this->assertEquals('mg', \D4w\Ect\Cep\Faixas::getEstado('31814-320')); + $this->assertEquals('ms', \D4w\Ect\Cep\Faixas::getEstado('79002-042')); + $this->assertEquals('mt', \D4w\Ect\Cep\Faixas::getEstado('78005-060')); + $this->assertEquals('pa', \D4w\Ect\Cep\Faixas::getEstado('67033-027')); + $this->assertEquals('pb', \D4w\Ect\Cep\Faixas::getEstado('58109-115')); + $this->assertEquals('pe', \D4w\Ect\Cep\Faixas::getEstado('53550-340')); + $this->assertEquals('pi', \D4w\Ect\Cep\Faixas::getEstado('64200-510')); + $this->assertEquals('pr', \D4w\Ect\Cep\Faixas::getEstado('83512-205')); + $this->assertEquals('rj', \D4w\Ect\Cep\Faixas::getEstado('23953-440')); + $this->assertEquals('rn', \D4w\Ect\Cep\Faixas::getEstado('59621-483')); + $this->assertEquals('ro', \D4w\Ect\Cep\Faixas::getEstado('78903-410')); + $this->assertEquals('rr', \D4w\Ect\Cep\Faixas::getEstado('69312-205')); + $this->assertEquals('rs', \D4w\Ect\Cep\Faixas::getEstado('96065-772')); + $this->assertEquals('sc', \D4w\Ect\Cep\Faixas::getEstado('89280-174')); + $this->assertEquals('se', \D4w\Ect\Cep\Faixas::getEstado('49087-446')); + $this->assertEquals('sp', \D4w\Ect\Cep\Faixas::getEstado('13475-214')); + $this->assertEquals('to', \D4w\Ect\Cep\Faixas::getEstado('77063-430')); + } + + public function testBrasilia() + { + $this->assertEquals('df', \D4w\Ect\Cep\Faixas::getEstado('72300-530')); + $this->assertEquals('df', \D4w\Ect\Cep\Faixas::getEstado('70278-070')); + $this->assertEquals('df', \D4w\Ect\Cep\Faixas::getEstado('71745-606')); + $this->assertEquals('df', \D4w\Ect\Cep\Faixas::getEstado('72331-006')); + } + + public function testGoias() + { + $this->assertEquals('go', \D4w\Ect\Cep\Faixas::getEstado('72912-445')); + $this->assertEquals('go', \D4w\Ect\Cep\Faixas::getEstado('72800-160')); + $this->assertEquals('go', \D4w\Ect\Cep\Faixas::getEstado('72800-160')); + } + + public function testIsCapital() + { + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('30180100')); // bh + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('05909200')); // sp + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('21123100')); // rj + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('29015123')); // es + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('40120000')); // ba + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('49080500')); // se + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('52999333')); // pe + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('57012100')); // al + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('58010500')); // pb + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('59025123')); // rn + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('60999123')); // ce + $this->assertTrue(\D4w\Ect\Cep\Faixas::isCapital('64099999')); // pi + } + +} \ No newline at end of file