From 41dff40252895825c54c007e88afb33350069b37 Mon Sep 17 00:00:00 2001 From: Henrique Holanda Date: Thu, 4 Oct 2018 10:02:44 -0300 Subject: [PATCH] Updating to PHP7 (#44) On this change, I'm doing some improvements to it works with new features of PHP (properties types, return types) --- README.md | 4 +- src/AbstractDocument.php | 39 +++++++++------ src/Cnh.php | 12 ++--- src/Cnpj.php | 8 +-- src/Cns.php | 8 +-- src/Cns/CnsCalculator.php | 2 +- src/Cns/TemporaryCalculator.php | 2 +- src/Cpf.php | 8 +-- src/DigitCalculable.php | 2 +- src/DigitCalculator.php | 30 ++++++------ src/Formattable.php | 2 +- src/JudiciaryProcess.php | 14 +++--- src/PisPasep.php | 8 +-- src/Renavam.php | 10 ++-- src/Sped/AbstractAccessKey.php | 26 +++++----- src/Sped/CTe.php | 12 ++--- src/Sped/CTeOther.php | 12 ++--- src/Sped/EmissionType.php | 22 ++++----- src/Sped/MDFe.php | 12 ++--- src/Sped/Model.php | 20 ++++---- src/Sped/NFCe.php | 12 ++--- src/Sped/NFe.php | 12 ++--- src/StateRegistration.php | 14 +++--- src/StateRegistration/Acre.php | 2 +- src/StateRegistration/Alagoas.php | 2 +- src/StateRegistration/Amapa.php | 12 ++--- src/StateRegistration/Amazonas.php | 2 +- src/StateRegistration/Bahia.php | 4 +- src/StateRegistration/Ceara.php | 2 +- src/StateRegistration/DistritoFederal.php | 2 +- src/StateRegistration/EspiritoSanto.php | 2 +- src/StateRegistration/Goias.php | 12 ++--- src/StateRegistration/Maranhao.php | 2 +- src/StateRegistration/MatoGrosso.php | 4 +- src/StateRegistration/MatoGrossoSul.php | 2 +- src/StateRegistration/MinasGerais.php | 2 +- src/StateRegistration/Para.php | 2 +- src/StateRegistration/Paraiba.php | 2 +- src/StateRegistration/Parana.php | 2 +- src/StateRegistration/Pernambuco.php | 20 ++++---- src/StateRegistration/Pernambuco/EFisco.php | 2 +- src/StateRegistration/Pernambuco/Old.php | 2 +- src/StateRegistration/Piaui.php | 2 +- src/StateRegistration/RioDeJaneiro.php | 2 +- src/StateRegistration/RioGrandeDoNorte.php | 12 ++--- src/StateRegistration/RioGrandeDoSul.php | 2 +- src/StateRegistration/Rondonia.php | 2 +- src/StateRegistration/Roraima.php | 2 +- src/StateRegistration/SantaCatarina.php | 2 +- src/StateRegistration/SaoPaulo.php | 20 ++++---- src/StateRegistration/SaoPaulo/Rural.php | 8 +-- src/StateRegistration/SaoPaulo/Urban.php | 10 ++-- src/StateRegistration/Sergipe.php | 2 +- src/StateRegistration/State.php | 18 +++---- src/StateRegistration/StateInterface.php | 16 +++--- src/StateRegistration/Tocantins.php | 20 ++++---- src/StateRegistration/Tocantins/Eleven.php | 6 +-- src/StateRegistration/Tocantins/Nine.php | 2 +- src/Voter.php | 16 +++--- tests/CnhTest.php | 13 ++--- tests/CnpjTest.php | 13 ++--- tests/CnsTest.php | 13 ++--- tests/CpfTest.php | 13 ++--- tests/DigitCalculatorTest.php | 2 +- tests/DocumentTestCase.php | 49 +++++-------------- tests/JudiciaryProcessTest.php | 13 ++--- tests/PisPasepTest.php | 13 ++--- tests/RenavamTest.php | 13 ++--- tests/Sped/CTeOtherTest.php | 15 +++--- tests/Sped/CTeTest.php | 15 +++--- tests/Sped/MDFeTest.php | 15 +++--- tests/Sped/NFCeTest.php | 15 +++--- tests/Sped/NFeTest.php | 15 +++--- tests/StateRegistration/AcreTest.php | 13 ++--- tests/StateRegistration/AlagoasTest.php | 13 ++--- tests/StateRegistration/AmapaTest.php | 13 ++--- tests/StateRegistration/AmazonasTest.php | 13 ++--- tests/StateRegistration/BahiaTest.php | 13 ++--- tests/StateRegistration/CearaTest.php | 13 ++--- .../StateRegistration/DistritoFederalTest.php | 13 ++--- tests/StateRegistration/EspiritoSantoTest.php | 13 ++--- tests/StateRegistration/GoiasTest.php | 13 ++--- tests/StateRegistration/MaranhaoTest.php | 13 ++--- tests/StateRegistration/MatoGrossoSulTest.php | 13 ++--- tests/StateRegistration/MatoGrossoTest.php | 13 ++--- tests/StateRegistration/MinasGeraisTest.php | 13 ++--- tests/StateRegistration/ParaTest.php | 13 ++--- tests/StateRegistration/ParaibaTest.php | 13 ++--- tests/StateRegistration/ParanaTest.php | 13 ++--- tests/StateRegistration/PernambucoTest.php | 13 ++--- tests/StateRegistration/PiauiTest.php | 13 ++--- tests/StateRegistration/RioDeJaneiroTest.php | 13 ++--- .../RioGrandeDoNorteTest.php | 13 ++--- .../StateRegistration/RioGrandeDoSulTest.php | 13 ++--- tests/StateRegistration/RondoniaTest.php | 13 ++--- tests/StateRegistration/RoraimaTest.php | 13 ++--- tests/StateRegistration/SantaCatarinaTest.php | 13 ++--- tests/StateRegistration/SaoPauloTest.php | 13 ++--- tests/StateRegistration/SergipeTest.php | 13 ++--- tests/StateRegistration/TocantinsTest.php | 13 ++--- tests/VoterTest.php | 13 ++--- 101 files changed, 559 insertions(+), 535 deletions(-) diff --git a/README.md b/README.md index 0fd1648..412f321 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Install the library using [composer][1]. Add the following to your `composer.jso ```json { "require": { - "brazanation/documents": "1.0.*" + "brazanation/documents": "2.0.*" } } ``` @@ -31,7 +31,7 @@ $ composer.phar install or ```sh -$ composer require brazanation/documents 1.0.* +$ composer require brazanation/documents 2.0.* ``` ### CPF (cadastro de pessoas fĂ­sicas) diff --git a/src/AbstractDocument.php b/src/AbstractDocument.php index 54dffd8..e4d7dd6 100644 --- a/src/AbstractDocument.php +++ b/src/AbstractDocument.php @@ -48,22 +48,26 @@ abstract class AbstractDocument implements DigitCalculable, Formattable * @param int $numberOfDigits Max length of checker digits. * @param string $type Document name/type. */ - public function __construct($number, $length, $numberOfDigits, $type) - { - $this->type = (string) $type; - $this->numberOfDigits = (int) $numberOfDigits; - $this->length = (int) $length; + public function __construct( + string $number, + int $length, + int $numberOfDigits, + string $type + ) { + $this->type = $type; + $this->numberOfDigits = $numberOfDigits; + $this->length = $length; $this->digit = $this->extractCheckerDigit($number); $this->assert($number); $this->number = $number; } - public function __get($name) + public function __get(string $name) { return $this->$name; } - public function __set($name, $value) + public function __set(string $name, string $value) { throw Exception\Readonly::notAllowed(static::class, $name); } @@ -75,7 +79,7 @@ public function __set($name, $value) * * @return AbstractDocument|boolean Returns a new Document instance or FALSE on failure. */ - abstract public static function createFromString($number); + abstract public static function createFromString(string $number); /** * Try to create a Document object from given number. @@ -87,8 +91,13 @@ abstract public static function createFromString($number); * * @return AbstractDocument|boolean Returns a new Document instance or FALSE on failure. */ - protected static function tryCreateFromString($class, $number, $length, $numberOfDigits, $type) - { + protected static function tryCreateFromString( + string $class, + string $number, + int $length, + int $numberOfDigits, + string $type + ) { try { return new $class($number, $length, $numberOfDigits, $type); } catch (Exception\InvalidDocument $exception) { @@ -101,7 +110,7 @@ protected static function tryCreateFromString($class, $number, $length, $numberO * * @return string */ - public function __toString() + public function __toString() : string { return "{$this->number}"; } @@ -114,7 +123,7 @@ public function __toString() * @throws Exception\InvalidDocument when number is empty * @throws Exception\InvalidDocument when number is not valid */ - protected function assert($number) + protected function assert(string $number) { if (empty($number)) { throw Exception\InvalidDocument::notEmpty($this->type); @@ -131,7 +140,7 @@ protected function assert($number) * * @return bool Returns true if it is a valid number, otherwise false. */ - protected function isValid($number) + protected function isValid(string $number) : bool { $baseNumber = $this->extractBaseNumber($number); @@ -157,7 +166,7 @@ protected function isValid($number) * * @return string Returns only base number without checker digit. */ - protected function extractBaseNumber($number) + protected function extractBaseNumber(string $number) : string { return substr($number, 0, -($this->numberOfDigits)); } @@ -169,7 +178,7 @@ protected function extractBaseNumber($number) * * @return string Returns only checker digit. */ - protected function extractCheckerDigit($number) + protected function extractCheckerDigit(string $number) : string { return substr($number, -($this->numberOfDigits)); } diff --git a/src/Cnh.php b/src/Cnh.php index e88d9ae..4afe794 100644 --- a/src/Cnh.php +++ b/src/Cnh.php @@ -17,13 +17,13 @@ final class Cnh extends AbstractDocument * * @param string $cnh Only accept numbers */ - public function __construct($cnh) + public function __construct(string $cnh) { $cnh = preg_replace('/\D/', '', $cnh); parent::__construct($cnh, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -31,7 +31,7 @@ public static function createFromString($number) /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $firstDigit = $this->calculateFirstDigit($baseNumber); $secondDigit = $this->calculateSecondDigit($baseNumber); @@ -42,7 +42,7 @@ public function calculateDigit($baseNumber) /** * {@inheritdoc} */ - public function format() + public function format() : string { return "{$this}"; } @@ -54,7 +54,7 @@ public function format() * * @return string Returns a calculated checker digit. */ - private function calculateFirstDigit($baseNumber) + private function calculateFirstDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliersInterval(1, 9); @@ -72,7 +72,7 @@ private function calculateFirstDigit($baseNumber) * * @return string Returns a calculated checker digit. */ - private function calculateSecondDigit($baseNumber) + private function calculateSecondDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliers([9, 8, 7, 6, 5, 4, 3, 2, 1]); diff --git a/src/Cnpj.php b/src/Cnpj.php index 7829c49..bb3964c 100644 --- a/src/Cnpj.php +++ b/src/Cnpj.php @@ -17,13 +17,13 @@ final class Cnpj extends AbstractDocument * * @param string $cnpj Only accept numbers */ - public function __construct($cnpj) + public function __construct(string $cnpj) { $cnpj = preg_replace('/\D/', '', $cnpj); parent::__construct($cnpj, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -31,7 +31,7 @@ public static function createFromString($number) /** * {@inheritdoc} */ - public function format() + public function format() : string { return preg_replace(self::REGEX, '$1.$2.$3/$4-$5', "{$this}"); } @@ -39,7 +39,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/Cns.php b/src/Cns.php index b1df3b4..97c91c6 100644 --- a/src/Cns.php +++ b/src/Cns.php @@ -22,13 +22,13 @@ final class Cns extends AbstractDocument * * @param string $number */ - public function __construct($number) + public function __construct(string $number) { $number = preg_replace('/\D/', '', $number); parent::__construct($number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -36,7 +36,7 @@ public static function createFromString($number) /** * {@inheritdoc} */ - public function format() + public function format() : string { return preg_replace(self::REGEX, self::FORMAT, "{$this}"); } @@ -49,7 +49,7 @@ public function format() * For numbers starting with 7, 8 or 9 will use TemporaryCalculator, * otherwise CnsCalculator. */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new CnsCalculator(); diff --git a/src/Cns/CnsCalculator.php b/src/Cns/CnsCalculator.php index 0d07103..88b32f0 100644 --- a/src/Cns/CnsCalculator.php +++ b/src/Cns/CnsCalculator.php @@ -10,7 +10,7 @@ final class CnsCalculator implements DigitCalculable /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $pis = substr($baseNumber, 0, 11); diff --git a/src/Cns/TemporaryCalculator.php b/src/Cns/TemporaryCalculator.php index ff34076..92fe61c 100644 --- a/src/Cns/TemporaryCalculator.php +++ b/src/Cns/TemporaryCalculator.php @@ -10,7 +10,7 @@ class TemporaryCalculator implements DigitCalculable /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliersInterval(1, 15); diff --git a/src/Cpf.php b/src/Cpf.php index fa34b43..6b597f8 100644 --- a/src/Cpf.php +++ b/src/Cpf.php @@ -17,13 +17,13 @@ final class Cpf extends AbstractDocument * * @param string $number Only accept numbers */ - public function __construct($number) + public function __construct(string $number) { $number = preg_replace('/\D/', '', $number); parent::__construct($number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -31,7 +31,7 @@ public static function createFromString($number) /** * @return string Returns formatted number, such as: 000.000.000-00 */ - public function format() + public function format() : string { return preg_replace(self::REGEX, '$1.$2.$3-$4', "{$this}"); } @@ -39,7 +39,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliersInterval(2, 11); diff --git a/src/DigitCalculable.php b/src/DigitCalculable.php index 0d4244d..11f3eec 100644 --- a/src/DigitCalculable.php +++ b/src/DigitCalculable.php @@ -11,5 +11,5 @@ interface DigitCalculable * * @return string Returns the checker digit. */ - public function calculateDigit($baseNumber); + public function calculateDigit(string $baseNumber) : string; } diff --git a/src/DigitCalculator.php b/src/DigitCalculator.php index 8fffeca..f0d09b9 100644 --- a/src/DigitCalculator.php +++ b/src/DigitCalculator.php @@ -82,7 +82,7 @@ class DigitCalculator * * @param string $number Base numeric section to be calculate your digit. */ - public function __construct($number) + public function __construct(string $number) { $this->number = new \ArrayObject(str_split(strrev($number))); $this->multipliers = new \ArrayObject(); @@ -107,7 +107,7 @@ public function __construct($number) * * @return DigitCalculator */ - public function withMultipliersInterval($start, $end) + public function withMultipliersInterval(int $start, int $end) : DigitCalculator { $multipliers = []; for ($i = $start; $i <= $end; ++$i) { @@ -127,7 +127,7 @@ public function withMultipliersInterval($start, $end) * * @return DigitCalculator */ - public function withMultipliers(array $multipliers) + public function withMultipliers(array $multipliers) : DigitCalculator { $multipliers = array_map(function ($multiplier) { if (!assert(is_int($multiplier))) { @@ -149,7 +149,7 @@ public function withMultipliers(array $multipliers) * * @return DigitCalculator */ - public function useComplementaryInsteadOfModule() + public function useComplementaryInsteadOfModule() : DigitCalculator { $this->additional = true; @@ -166,7 +166,7 @@ public function useComplementaryInsteadOfModule() * * @return DigitCalculator */ - public function replaceWhen($replaceTo, ...$integers) + public function replaceWhen(string $replaceTo, ...$integers) : DigitCalculator { foreach ($integers as $integer) { $this->replacements->offsetSet($integer, $replaceTo); @@ -184,7 +184,7 @@ public function replaceWhen($replaceTo, ...$integers) * * @return DigitCalculator */ - public function withModule($module) + public function withModule(int $module) : DigitCalculator { $this->module = $module; @@ -199,7 +199,7 @@ public function withModule($module) * * @return DigitCalculator */ - public function singleSum() + public function singleSum() : DigitCalculator { $this->singleSum = true; @@ -211,7 +211,7 @@ public function singleSum() * * @return string Returns a single calculated digit. */ - public function calculate() + public function calculate() : string { $sum = 0; $position = 0; @@ -238,7 +238,7 @@ public function calculate() * * @return string Returns digit replaced if it has been mapped, otherwise returns given digit. */ - private function replaceDigit($digit) + private function replaceDigit(string $digit) : string { if ($this->replacements->offsetExists($digit)) { return $this->replacements->offsetGet($digit); @@ -254,7 +254,7 @@ private function replaceDigit($digit) * * @return int Returns calculated digit. */ - private function calculateAdditionalDigit($digit) + private function calculateAdditionalDigit(string $digit) : int { if ($this->additional) { $digit = $this->module - $digit; @@ -270,7 +270,7 @@ private function calculateAdditionalDigit($digit) * * @return int Returns a calculated total. */ - private function calculateSingleSum($total) + private function calculateSingleSum(int $total) : int { if ($this->singleSum) { return intval(($total / 10) + ($total % 10)); @@ -286,7 +286,7 @@ private function calculateSingleSum($total) * * @return int Returns next position or zero (0) when it is greater than number of defined multipliers. */ - private function nextMultiplier($position) + private function nextMultiplier(int $position) : int { ++$position; if ($position == $this->multipliers->count()) { @@ -303,7 +303,7 @@ private function nextMultiplier($position) * * @return DigitCalculator */ - public function addDigit($digit) + public function addDigit(string $digit) : DigitCalculator { $numbers = $this->number->getArrayCopy(); array_unshift($numbers, $digit); @@ -319,7 +319,7 @@ public function addDigit($digit) * * @return DigitCalculator */ - public function multiplySumBy($multiplier) + public function multiplySumBy(int $multiplier) : DigitCalculator { $this->sumMultiplier = $multiplier; @@ -333,7 +333,7 @@ public function multiplySumBy($multiplier) * * @return int */ - private function calculateSumMultiplier($sum) + private function calculateSumMultiplier(int $sum) : int { return $this->sumMultiplier * $sum; } diff --git a/src/Formattable.php b/src/Formattable.php index c5a63bd..3fe55b3 100644 --- a/src/Formattable.php +++ b/src/Formattable.php @@ -9,5 +9,5 @@ interface Formattable * * @return string Returns formatted number. */ - public function format(); + public function format() : string ; } diff --git a/src/JudiciaryProcess.php b/src/JudiciaryProcess.php index ef928b2..d25aed7 100644 --- a/src/JudiciaryProcess.php +++ b/src/JudiciaryProcess.php @@ -59,14 +59,14 @@ final class JudiciaryProcess extends AbstractDocument */ private $origin; - public function __construct($number) + public function __construct(string $number) { $number = preg_replace('/\D/', '', $number); $this->extractNumbers($number); parent::__construct($number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -76,7 +76,7 @@ public static function createFromString($number) * * @param string $number */ - private function extractNumbers($number) + private function extractNumbers(string $number) { $number = str_pad($number, self::LENGTH, '0', STR_PAD_RIGHT); @@ -88,19 +88,19 @@ private function extractNumbers($number) $this->origin = $matches[6]; } - public function format() + public function format() : string { $number = str_pad($this->number, self::LENGTH, '0', STR_PAD_RIGHT); return preg_replace(self::REGEX, '$1-$2.$3.$4.$5.$6', "{$number}"); } - protected function extractCheckerDigit($number) + protected function extractCheckerDigit(string $number) : string { return substr($number, 7, 2); } - protected function extractBaseNumber($number) + protected function extractBaseNumber(string $number) : string { return "{$this->sequentialNumber}{$this->year}{$this->judiciary}{$this->court}{$this->origin}"; } @@ -116,7 +116,7 @@ protected function extractBaseNumber($number) * * @return string */ - public function calculateDigit($input) + public function calculateDigit(string $input) : string { $remainderNumber = intval($this->sequentialNumber) % 97; diff --git a/src/PisPasep.php b/src/PisPasep.php index e173118..d17d6b1 100644 --- a/src/PisPasep.php +++ b/src/PisPasep.php @@ -17,13 +17,13 @@ final class PisPasep extends AbstractDocument * * @param $number */ - public function __construct($number) + public function __construct(string $number) { $number = preg_replace('/\D/', '', $number); parent::__construct($number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -31,7 +31,7 @@ public static function createFromString($number) /** * @return string Returns formatted number, such as: 00.00000.00-0 */ - public function format() + public function format() : string { return preg_replace(self::REGEX, '$1.$2.$3-$4', "{$this}"); } @@ -39,7 +39,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliersInterval(2, 9); diff --git a/src/Renavam.php b/src/Renavam.php index fe4d6c3..126935d 100644 --- a/src/Renavam.php +++ b/src/Renavam.php @@ -17,14 +17,14 @@ final class Renavam extends AbstractDocument * * @param string $renavam Only accept numbers */ - public function __construct($renavam) + public function __construct(string $renavam) { $renavam = preg_replace('/\D/', '', $renavam); $renavam = $this->padNumber($renavam); parent::__construct($renavam, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -36,7 +36,7 @@ public static function createFromString($number) * * @return string */ - private function padNumber($number) + private function padNumber(string $number) : string { if (empty($number)) { return ''; @@ -48,7 +48,7 @@ private function padNumber($number) /** * {@inheritdoc} */ - public function format() + public function format() : string { return preg_replace(self::REGEX, '$1.$2-$3', "{$this}"); } @@ -56,7 +56,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); //$calculator->withMultipliers([3, 2, 9, 8, 7, 6, 5, 4, 3, 2]); diff --git a/src/Sped/AbstractAccessKey.php b/src/Sped/AbstractAccessKey.php index cb21d5f..4865982 100644 --- a/src/Sped/AbstractAccessKey.php +++ b/src/Sped/AbstractAccessKey.php @@ -78,7 +78,7 @@ abstract class AbstractAccessKey extends AbstractDocument * * @param $accessKey */ - public function __construct($accessKey) + public function __construct(string $accessKey) { $accessKey = preg_replace('/\D/', '', $accessKey); parent::__construct($accessKey, static::LENGTH, static::NUMBER_OF_DIGITS, static::LABEL); @@ -86,7 +86,7 @@ public function __construct($accessKey) $this->loadFromKey($accessKey); } - public static function createFromString($number) + public static function createFromString(string $number) { return parent::tryCreateFromString(static::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -94,9 +94,9 @@ public static function createFromString($number) /** * @return Model */ - abstract protected function defaultModel(); + abstract protected function defaultModel() : Model; - protected function validateModel($accessKey) + protected function validateModel(string $accessKey) { $model = new Model(substr($accessKey, 20, 2)); if (!$this->defaultModel()->equalsTo($model)) { @@ -104,7 +104,7 @@ protected function validateModel($accessKey) } } - private function loadFromKey($accessKey) + private function loadFromKey(string $accessKey) { $startPosition = 0; $this->state = substr($accessKey, $startPosition, 2); @@ -149,15 +149,15 @@ private function loadFromKey($accessKey) * @return AbstractAccessKey */ protected static function generateKey( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, Model $model, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $yearMonth = $generatedAt->format('ym'); $sequence = str_pad($sequence, 3, 0, STR_PAD_LEFT); $invoiceNumber = str_pad($invoiceNumber, 9, 0, STR_PAD_LEFT); @@ -176,7 +176,7 @@ protected static function generateKey( /** * {@inheritdoc} */ - public function format() + public function format() : string { return trim(preg_replace(self::REGEX, self::MASK, "{$this}")); } @@ -184,7 +184,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { return self::calculateDigitFrom($baseNumber); } @@ -198,7 +198,7 @@ public function calculateDigit($baseNumber) * * @return string */ - public static function calculateDigitFrom($baseNumber) + public static function calculateDigitFrom(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/Sped/CTe.php b/src/Sped/CTe.php index 58e87ca..24b9a69 100644 --- a/src/Sped/CTe.php +++ b/src/Sped/CTe.php @@ -8,7 +8,7 @@ final class CTe extends AbstractAccessKey { const LABEL = 'CTe'; - protected function defaultModel() + protected function defaultModel() : Model { return Model::CTe(); } @@ -27,14 +27,14 @@ protected function defaultModel() * @return NFe */ public static function generate( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $accessKey = self::generateKey( $state, $generatedAt, diff --git a/src/Sped/CTeOther.php b/src/Sped/CTeOther.php index 75a22a8..9efb3f6 100644 --- a/src/Sped/CTeOther.php +++ b/src/Sped/CTeOther.php @@ -8,7 +8,7 @@ final class CTeOther extends AbstractAccessKey { const LABEL = 'CTeOther'; - protected function defaultModel() + protected function defaultModel() : Model { return Model::CTeOther(); } @@ -27,14 +27,14 @@ protected function defaultModel() * @return NFe */ public static function generate( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $accessKey = self::generateKey( $state, $generatedAt, diff --git a/src/Sped/EmissionType.php b/src/Sped/EmissionType.php index d0462fa..d8946d2 100644 --- a/src/Sped/EmissionType.php +++ b/src/Sped/EmissionType.php @@ -37,55 +37,55 @@ class EmissionType * * @param int $type */ - public function __construct($type) + public function __construct(int $type) { $this->validate($type); - $this->type = (int) $type; + $this->type = $type; } - private function validate($type) + private function validate(int $type) { if (!in_array($type, $this->allowed)) { throw InvalidEmissionType::notAllowed($type); } } - public static function normal() + public static function normal() : EmissionType { return new self(self::NORMAL); } - public static function contingencyDpec() + public static function contingencyDpec() : EmissionType { return new self(self::CONTINGENCY_DPEC); } - public static function contingencySVCRS() + public static function contingencySVCRS() : EmissionType { return new self(self::CONTINGENCY_SVCRS); } - public static function contingencySVCAN() + public static function contingencySVCAN() : EmissionType { return new self(self::CONTINGENCY_SVCAN); } - public static function contingencySCAN() + public static function contingencySCAN() : EmissionType { return new self(self::CONTINGENCY_SCAN); } - public static function contingencyOnSafetyForm() + public static function contingencyOnSafetyForm() : EmissionType { return new self(self::CONTINGENCY_ON_SAFETY_FORM); } - public static function contingencyOnSafetyFormFSDA() + public static function contingencyOnSafetyFormFSDA() : EmissionType { return new self(self::CONTINGENCY_ON_SAFETY_FORM_FSDA); } - public function __toString() + public function __toString() : string { return "{$this->type}"; } diff --git a/src/Sped/MDFe.php b/src/Sped/MDFe.php index d43b813..d8d4e0c 100644 --- a/src/Sped/MDFe.php +++ b/src/Sped/MDFe.php @@ -8,7 +8,7 @@ final class MDFe extends AbstractAccessKey { const LABEL = 'MDFe'; - protected function defaultModel() + protected function defaultModel() : Model { return Model::MDFe(); } @@ -27,14 +27,14 @@ protected function defaultModel() * @return NFe */ public static function generate( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $accessKey = self::generateKey( $state, $generatedAt, diff --git a/src/Sped/Model.php b/src/Sped/Model.php index b6fcf1a..d014e9e 100644 --- a/src/Sped/Model.php +++ b/src/Sped/Model.php @@ -31,50 +31,50 @@ class Model * * @param int $model */ - public function __construct($model) + public function __construct(int $model) { $this->validate($model); - $this->model = (int) $model; + $this->model = $model; } - private function validate($model) + private function validate(int $model) { if (!in_array($model, $this->allowed)) { throw InvalidModel::notAllowed($model); } } - public static function NFe() + public static function NFe() : Model { return new self(self::TYPE_NFE); } - public static function NFCe() + public static function NFCe() : Model { return new self(self::TYPE_NFCE); } - public static function CTe() + public static function CTe() : Model { return new self(self::TYPE_CTE); } - public static function CTeOther() + public static function CTeOther() : Model { return new self(self::TYPE_CTE_OTHER); } - public static function MDFe() + public static function MDFe() : Model { return new self(self::TYPE_MDFE); } - public function equalsTo(Model $model) + public function equalsTo(Model $model) : bool { return $this->model === $model->model; } - public function __toString() + public function __toString() : string { return "{$this->model}"; } diff --git a/src/Sped/NFCe.php b/src/Sped/NFCe.php index 91c73d0..f6782f7 100644 --- a/src/Sped/NFCe.php +++ b/src/Sped/NFCe.php @@ -8,7 +8,7 @@ final class NFCe extends AbstractAccessKey { const LABEL = 'NFCe'; - protected function defaultModel() + protected function defaultModel() : Model { return Model::NFCe(); } @@ -27,14 +27,14 @@ protected function defaultModel() * @return NFe */ public static function generate( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $accessKey = self::generateKey( $state, $generatedAt, diff --git a/src/Sped/NFe.php b/src/Sped/NFe.php index c316f49..905a6a0 100644 --- a/src/Sped/NFe.php +++ b/src/Sped/NFe.php @@ -8,7 +8,7 @@ final class NFe extends AbstractAccessKey { const LABEL = 'NFe'; - protected function defaultModel() + protected function defaultModel() : Model { return Model::NFe(); } @@ -27,14 +27,14 @@ protected function defaultModel() * @return NFe */ public static function generate( - $state, + int $state, \DateTime $generatedAt, Cnpj $cnpj, - $sequence, - $invoiceNumber, + int $sequence, + int $invoiceNumber, EmissionType $emissionType, - $controlNumber - ) { + int $controlNumber + ) : AbstractAccessKey { $accessKey = self::generateKey( $state, $generatedAt, diff --git a/src/StateRegistration.php b/src/StateRegistration.php index 03604ff..d5346ae 100644 --- a/src/StateRegistration.php +++ b/src/StateRegistration.php @@ -81,7 +81,7 @@ final class StateRegistration extends AbstractDocument * @param string $number * @param StateRegistration\StateInterface $state */ - public function __construct($number, StateRegistration\StateInterface $state) + public function __construct(string $number, StateRegistration\StateInterface $state) { $number = $state->normalizeNumber($number); $this->state = $state; @@ -96,7 +96,7 @@ public function __construct($number, StateRegistration\StateInterface $state) * * @return AbstractDocument|boolean Returns a new Document instance or FALSE on failure. */ - public static function createFromString($number, $state = '') + public static function createFromString(string $number, string $state = '') { try { return static::$state($number); @@ -113,7 +113,7 @@ public static function createFromString($number, $state = '') * * @throws \ReflectionException */ - public static function __callStatic($name, $arguments) + public static function __callStatic(string $name, array $arguments) { $class = self::$availableStates[$name]; $reflection = new \ReflectionClass($class); @@ -127,7 +127,7 @@ public static function __callStatic($name, $arguments) /** * {@inheritdoc} */ - protected function extractBaseNumber($number) + protected function extractBaseNumber(string $number) : string { return $this->state->extractBaseNumber($number); } @@ -135,7 +135,7 @@ protected function extractBaseNumber($number) /** * {@inheritdoc} */ - protected function extractCheckerDigit($number) + protected function extractCheckerDigit(string $number) : string { return $this->state->extractCheckerDigit($number); } @@ -145,7 +145,7 @@ protected function extractCheckerDigit($number) * * @return string Returns only numbers. */ - public function format() + public function format() : string { return preg_replace($this->state->getRegex(), $this->state->getFormat(), "{$this}"); } @@ -153,7 +153,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $digit = $this->state->calculateDigit($baseNumber); diff --git a/src/StateRegistration/Acre.php b/src/StateRegistration/Acre.php index a16057b..561cd4a 100644 --- a/src/StateRegistration/Acre.php +++ b/src/StateRegistration/Acre.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_AC.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Alagoas.php b/src/StateRegistration/Alagoas.php index 086bcfe..b136bd1 100644 --- a/src/StateRegistration/Alagoas.php +++ b/src/StateRegistration/Alagoas.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_AL.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Amapa.php b/src/StateRegistration/Amapa.php index a418b10..a317909 100644 --- a/src/StateRegistration/Amapa.php +++ b/src/StateRegistration/Amapa.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_AP.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $number = intval($baseNumber); $lastDigit = $this->discoverLastDigit($number); @@ -53,7 +53,7 @@ public function calculateDigit($baseNumber) * * @return string */ - private function discoverLastDigit($number) + private function discoverLastDigit(int $number) : string { $lastDigit = '0'; if ($this->isBetweenFirstSlice($number)) { @@ -69,11 +69,11 @@ private function discoverLastDigit($number) /** * Discover digit to be replaced based on number threshold. * - * @param $number + * @param int $number * * @return string */ - private function discoverDigitToReplace($number) + private function discoverDigitToReplace(int $number) : string { $replaceDigit = '0'; if ($this->isBetweenSecondSlice($number)) { @@ -90,7 +90,7 @@ private function discoverDigitToReplace($number) * * @return bool */ - private function isBetweenFirstSlice($number) + private function isBetweenFirstSlice(int $number) : bool { return (3000001 <= $number && $number <= 3017000); } @@ -102,7 +102,7 @@ private function isBetweenFirstSlice($number) * * @return bool */ - private function isBetweenSecondSlice($number) + private function isBetweenSecondSlice(int $number) : bool { return (3017001 <= $number && $number <= 3019022); } diff --git a/src/StateRegistration/Amazonas.php b/src/StateRegistration/Amazonas.php index dd1a3ce..6c9d9d4 100644 --- a/src/StateRegistration/Amazonas.php +++ b/src/StateRegistration/Amazonas.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_AM.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Bahia.php b/src/StateRegistration/Bahia.php index ff63dc8..fe86901 100644 --- a/src/StateRegistration/Bahia.php +++ b/src/StateRegistration/Bahia.php @@ -27,7 +27,7 @@ public function __construct() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { if (!empty($number)) { return str_pad(parent::normalizeNumber($number), $this->getLength(), '0', STR_PAD_LEFT); @@ -41,7 +41,7 @@ public function normalizeNumber($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_BA.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Ceara.php b/src/StateRegistration/Ceara.php index 7b20d80..43b3f66 100644 --- a/src/StateRegistration/Ceara.php +++ b/src/StateRegistration/Ceara.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_CE.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/DistritoFederal.php b/src/StateRegistration/DistritoFederal.php index 0ebfa04..fc94580 100644 --- a/src/StateRegistration/DistritoFederal.php +++ b/src/StateRegistration/DistritoFederal.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_DF.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/EspiritoSanto.php b/src/StateRegistration/EspiritoSanto.php index 7fb796c..a48a8da 100644 --- a/src/StateRegistration/EspiritoSanto.php +++ b/src/StateRegistration/EspiritoSanto.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_ES.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Goias.php b/src/StateRegistration/Goias.php index 8209b9e..56bdd1c 100644 --- a/src/StateRegistration/Goias.php +++ b/src/StateRegistration/Goias.php @@ -34,7 +34,7 @@ public function __construct() * * @return Goias */ - private function setCurrentDigit($digit) + private function setCurrentDigit(string $digit) { $this->digit = $digit; @@ -46,7 +46,7 @@ private function setCurrentDigit($digit) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_GO.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $digitToReplace = $this->discoverDigitToReplace(intval($baseNumber)); @@ -74,7 +74,7 @@ public function calculateDigit($baseNumber) * * @return bool Returns true if number is magic, otherwise false. */ - private function isMagicNumber($number) + private function isMagicNumber(string $number) : bool { return $number == '11094402'; } @@ -86,7 +86,7 @@ private function isMagicNumber($number) * * @return string */ - private function fixedDigitForMagicNumber($digit) + private function fixedDigitForMagicNumber(string $digit) : string { if ($digit == $this->digit && $digit == '0') { return '0'; @@ -95,7 +95,7 @@ private function fixedDigitForMagicNumber($digit) return '1'; } - private function discoverDigitToReplace($number) + private function discoverDigitToReplace(string $number) : string { $digitToReplace = '0'; if ((10103105 <= $number) && ($number <= 10119997)) { @@ -105,7 +105,7 @@ private function discoverDigitToReplace($number) return $digitToReplace; } - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { $number = parent::normalizeNumber($number); $this->setCurrentDigit(substr($number, -($this->getNumberOfDigits()))); diff --git a/src/StateRegistration/Maranhao.php b/src/StateRegistration/Maranhao.php index c53aed1..f018792 100644 --- a/src/StateRegistration/Maranhao.php +++ b/src/StateRegistration/Maranhao.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_MA.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/MatoGrosso.php b/src/StateRegistration/MatoGrosso.php index a57887a..61c77ec 100644 --- a/src/StateRegistration/MatoGrosso.php +++ b/src/StateRegistration/MatoGrosso.php @@ -23,7 +23,7 @@ public function __construct() parent::__construct(self::LONG_NAME, self::LENGTH, self::NUMBER_OF_DIGITS, self::REGEX, self::FORMAT); } - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { if (!empty($number)) { return str_pad(parent::normalizeNumber($number), $this->getLength(), '0', STR_PAD_LEFT); @@ -37,7 +37,7 @@ public function normalizeNumber($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_MT.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/MatoGrossoSul.php b/src/StateRegistration/MatoGrossoSul.php index 4f7cfcd..d6a4f48 100644 --- a/src/StateRegistration/MatoGrossoSul.php +++ b/src/StateRegistration/MatoGrossoSul.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_MS.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/MinasGerais.php b/src/StateRegistration/MinasGerais.php index 7635228..5126820 100644 --- a/src/StateRegistration/MinasGerais.php +++ b/src/StateRegistration/MinasGerais.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_MG.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Para.php b/src/StateRegistration/Para.php index cf0069a..8029b7a 100644 --- a/src/StateRegistration/Para.php +++ b/src/StateRegistration/Para.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PA.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Paraiba.php b/src/StateRegistration/Paraiba.php index 42a4b7e..c476ae9 100644 --- a/src/StateRegistration/Paraiba.php +++ b/src/StateRegistration/Paraiba.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PB.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Parana.php b/src/StateRegistration/Parana.php index ab65226..aba4588 100644 --- a/src/StateRegistration/Parana.php +++ b/src/StateRegistration/Parana.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PR.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Pernambuco.php b/src/StateRegistration/Pernambuco.php index 691efc9..bd98f62 100644 --- a/src/StateRegistration/Pernambuco.php +++ b/src/StateRegistration/Pernambuco.php @@ -24,7 +24,7 @@ public function __construct() /** * {@inheritdoc} */ - public function getState() + public function getState() : string { return $this->calculation->getState(); } @@ -32,7 +32,7 @@ public function getState() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { $this->defineStrategy($number); @@ -42,7 +42,7 @@ public function normalizeNumber($number) /** * {@inheritdoc} */ - public function getLength() + public function getLength() : int { return $this->calculation->getLength(); } @@ -50,7 +50,7 @@ public function getLength() /** * {@inheritdoc} */ - public function getFormat() + public function getFormat() : string { return $this->calculation->getFormat(); } @@ -58,7 +58,7 @@ public function getFormat() /** * {@inheritdoc} */ - public function getNumberOfDigits() + public function getNumberOfDigits() : int { return $this->calculation->getNumberOfDigits(); } @@ -66,7 +66,7 @@ public function getNumberOfDigits() /** * {@inheritdoc} */ - public function getRegex() + public function getRegex() : string { return $this->calculation->getRegex(); } @@ -76,7 +76,7 @@ public function getRegex() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PE.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { return $this->calculation->calculateDigit($baseNumber); } @@ -84,7 +84,7 @@ public function calculateDigit($baseNumber) /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return $this->calculation->extractBaseNumber($number); } @@ -92,7 +92,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return $this->calculation->extractCheckerDigit($number); } @@ -102,7 +102,7 @@ public function extractCheckerDigit($number) * * @param string $number Number of document. */ - private function defineStrategy($number) + private function defineStrategy(string $number) { $number = preg_replace('/\D/', '', $number); if ($this->calculation->getLength() != strlen($number)) { diff --git a/src/StateRegistration/Pernambuco/EFisco.php b/src/StateRegistration/Pernambuco/EFisco.php index b482be9..9d407ec 100644 --- a/src/StateRegistration/Pernambuco/EFisco.php +++ b/src/StateRegistration/Pernambuco/EFisco.php @@ -26,7 +26,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PE.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Pernambuco/Old.php b/src/StateRegistration/Pernambuco/Old.php index 0bf152e..e66aa55 100644 --- a/src/StateRegistration/Pernambuco/Old.php +++ b/src/StateRegistration/Pernambuco/Old.php @@ -26,7 +26,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PE.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber . '0'); $calculator->withMultipliersInterval(1, 9); diff --git a/src/StateRegistration/Piaui.php b/src/StateRegistration/Piaui.php index 0f05324..6c8d4c7 100644 --- a/src/StateRegistration/Piaui.php +++ b/src/StateRegistration/Piaui.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_PI.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/RioDeJaneiro.php b/src/StateRegistration/RioDeJaneiro.php index 146988d..b1a20bf 100644 --- a/src/StateRegistration/RioDeJaneiro.php +++ b/src/StateRegistration/RioDeJaneiro.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_RJ.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/RioGrandeDoNorte.php b/src/StateRegistration/RioGrandeDoNorte.php index 6a250da..79b5134 100644 --- a/src/StateRegistration/RioGrandeDoNorte.php +++ b/src/StateRegistration/RioGrandeDoNorte.php @@ -48,7 +48,7 @@ public function __construct() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { $number = parent::normalizeNumber($number); @@ -57,12 +57,12 @@ public function normalizeNumber($number) return $number; } - public function getFormat() + public function getFormat() : string { return $this->format; } - public function getLength() + public function getLength() : int { return $this->length; } @@ -70,7 +70,7 @@ public function getLength() /** * @return string */ - public function getRegex() + public function getRegex() : string { return $this->regex; } @@ -80,7 +80,7 @@ public function getRegex() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_RN.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); @@ -96,7 +96,7 @@ public function calculateDigit($baseNumber) /** * @param string $number */ - private function applyForNineDigits($number) + private function applyForNineDigits(string $number) { if (strlen($number) != self::LENGTH) { $this->format = self::FORMAT_FOR_NINE_NUMBERS; diff --git a/src/StateRegistration/RioGrandeDoSul.php b/src/StateRegistration/RioGrandeDoSul.php index 04c8162..e455e4b 100644 --- a/src/StateRegistration/RioGrandeDoSul.php +++ b/src/StateRegistration/RioGrandeDoSul.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_RS.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Rondonia.php b/src/StateRegistration/Rondonia.php index 10ff53d..3897acd 100644 --- a/src/StateRegistration/Rondonia.php +++ b/src/StateRegistration/Rondonia.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_RO.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/Roraima.php b/src/StateRegistration/Roraima.php index e0cb7a7..7183681 100644 --- a/src/StateRegistration/Roraima.php +++ b/src/StateRegistration/Roraima.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_RR.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliers([8, 7, 6, 5, 4, 3, 2, 1]); diff --git a/src/StateRegistration/SantaCatarina.php b/src/StateRegistration/SantaCatarina.php index 077dc37..1f44290 100644 --- a/src/StateRegistration/SantaCatarina.php +++ b/src/StateRegistration/SantaCatarina.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_SC.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/SaoPaulo.php b/src/StateRegistration/SaoPaulo.php index 36234e2..0a221d5 100644 --- a/src/StateRegistration/SaoPaulo.php +++ b/src/StateRegistration/SaoPaulo.php @@ -24,7 +24,7 @@ public function __construct() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { $this->defineStrategy($number); @@ -36,7 +36,7 @@ public function normalizeNumber($number) /** * {@inheritdoc} */ - public function getState() + public function getState() : string { return $this->calculation->getState(); } @@ -44,7 +44,7 @@ public function getState() /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return $this->calculation->extractBaseNumber($number); } @@ -52,7 +52,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return $this->calculation->extractCheckerDigit($number); } @@ -60,7 +60,7 @@ public function extractCheckerDigit($number) /** * {@inheritdoc} */ - public function getLength() + public function getLength() : int { return $this->calculation->getLength(); } @@ -68,7 +68,7 @@ public function getLength() /** * {@inheritdoc} */ - public function getFormat() + public function getFormat() : string { return $this->calculation->getFormat(); } @@ -76,7 +76,7 @@ public function getFormat() /** * {@inheritdoc} */ - public function getNumberOfDigits() + public function getNumberOfDigits() : int { return $this->calculation->getNumberOfDigits(); } @@ -84,7 +84,7 @@ public function getNumberOfDigits() /** * {@inheritdoc} */ - public function getRegex() + public function getRegex() : string { return $this->calculation->getRegex(); } @@ -94,7 +94,7 @@ public function getRegex() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_SP.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { return $this->calculation->calculateDigit($baseNumber); } @@ -104,7 +104,7 @@ public function calculateDigit($baseNumber) * * @param string $number Number of document. */ - private function defineStrategy($number) + private function defineStrategy(string $number) { if (strpos($number, 'P') !== false) { $this->calculation = new Rural(); diff --git a/src/StateRegistration/SaoPaulo/Rural.php b/src/StateRegistration/SaoPaulo/Rural.php index 560082a..9e669a2 100644 --- a/src/StateRegistration/SaoPaulo/Rural.php +++ b/src/StateRegistration/SaoPaulo/Rural.php @@ -24,7 +24,7 @@ public function __construct() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { return 'P' . preg_replace('/[\D]/i', '', $number); } @@ -32,7 +32,7 @@ public function normalizeNumber($number) /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return substr($number, 1, self::LENGTH - 4); } @@ -40,7 +40,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return substr($number, -4, 1); } @@ -50,7 +50,7 @@ public function extractCheckerDigit($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_SP.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliers([10, 8, 7, 6, 5, 4, 3, 1]); diff --git a/src/StateRegistration/SaoPaulo/Urban.php b/src/StateRegistration/SaoPaulo/Urban.php index 4ff4b4c..4b4cebb 100644 --- a/src/StateRegistration/SaoPaulo/Urban.php +++ b/src/StateRegistration/SaoPaulo/Urban.php @@ -26,7 +26,7 @@ public function __construct() * * No extract any digit */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return $number; } @@ -34,7 +34,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return substr($number, self::LENGTH - 4, 1) . substr($number, -1); } @@ -44,7 +44,7 @@ public function extractCheckerDigit($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_SP.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $firstBaseNumber = substr($baseNumber, 0, 8); @@ -57,7 +57,7 @@ public function calculateDigit($baseNumber) return "{$firstDigit}{$secondDigit}"; } - private function calculateFirstDigit($baseNumber) + private function calculateFirstDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliers([10, 8, 7, 6, 5, 4, 3, 1]); @@ -69,7 +69,7 @@ private function calculateFirstDigit($baseNumber) return "{$digit}"; } - private function calculateSecondDigit($baseNumber) + private function calculateSecondDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->withMultipliersInterval(2, 10); diff --git a/src/StateRegistration/Sergipe.php b/src/StateRegistration/Sergipe.php index 958ca97..17f39f6 100644 --- a/src/StateRegistration/Sergipe.php +++ b/src/StateRegistration/Sergipe.php @@ -28,7 +28,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_SE.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/StateRegistration/State.php b/src/StateRegistration/State.php index 04d5a6a..3953745 100644 --- a/src/StateRegistration/State.php +++ b/src/StateRegistration/State.php @@ -38,7 +38,7 @@ abstract class State implements StateInterface * @param string $regex * @param string $format */ - public function __construct($state, $length, $numberOfDigits, $regex, $format) + public function __construct(string $state, int $length, int $numberOfDigits, string $regex, string $format) { $this->state = $state; $this->length = $length; @@ -50,7 +50,7 @@ public function __construct($state, $length, $numberOfDigits, $regex, $format) /** * {@inheritdoc} */ - public function getState() + public function getState() : string { return $this->state; } @@ -58,7 +58,7 @@ public function getState() /** * {@inheritdoc} */ - public function getLength() + public function getLength() : int { return $this->length; } @@ -66,7 +66,7 @@ public function getLength() /** * {@inheritdoc} */ - public function getRegex() + public function getRegex() : string { return $this->regex; } @@ -74,7 +74,7 @@ public function getRegex() /** * {@inheritdoc} */ - public function getFormat() + public function getFormat() : string { return $this->format; } @@ -82,7 +82,7 @@ public function getFormat() /** * {@inheritdoc} */ - public function getNumberOfDigits() + public function getNumberOfDigits() : int { return $this->numberOfDigits; } @@ -90,7 +90,7 @@ public function getNumberOfDigits() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { return preg_replace('/\D/', '', $number); } @@ -98,7 +98,7 @@ public function normalizeNumber($number) /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return substr($number, 0, -($this->getNumberOfDigits())); } @@ -106,7 +106,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return substr($number, -($this->getNumberOfDigits())); } diff --git a/src/StateRegistration/StateInterface.php b/src/StateRegistration/StateInterface.php index 62e1c9c..2efeee6 100644 --- a/src/StateRegistration/StateInterface.php +++ b/src/StateRegistration/StateInterface.php @@ -9,27 +9,27 @@ interface StateInterface extends DigitCalculable /** * @return string */ - public function getState(); + public function getState() : string; /** * @return int */ - public function getLength(); + public function getLength() : int; /** * @return string */ - public function getRegex(); + public function getRegex() : string; /** * @return string */ - public function getFormat(); + public function getFormat() : string; /** * @return int */ - public function getNumberOfDigits(); + public function getNumberOfDigits() : int; /** * Normalizes number removing non-digit chars. @@ -38,7 +38,7 @@ public function getNumberOfDigits(); * * @return string Returns only numbers. */ - public function normalizeNumber($number); + public function normalizeNumber(string $number) : string; /** * Extracts base number from document number. @@ -47,7 +47,7 @@ public function normalizeNumber($number); * * @return string Returns only base number without checker digit. */ - public function extractBaseNumber($number); + public function extractBaseNumber(string $number) : string; /** * Extracts the checker digit from document number. @@ -56,5 +56,5 @@ public function extractBaseNumber($number); * * @return string Returns only checker digit. */ - public function extractCheckerDigit($number); + public function extractCheckerDigit(string $number) : string; } diff --git a/src/StateRegistration/Tocantins.php b/src/StateRegistration/Tocantins.php index 79eff7a..de52135 100644 --- a/src/StateRegistration/Tocantins.php +++ b/src/StateRegistration/Tocantins.php @@ -24,7 +24,7 @@ public function __construct() /** * {@inheritdoc} */ - public function getState() + public function getState() : string { return $this->calculation->getState(); } @@ -32,7 +32,7 @@ public function getState() /** * {@inheritdoc} */ - public function getLength() + public function getLength() : int { return $this->calculation->getLength(); } @@ -40,7 +40,7 @@ public function getLength() /** * {@inheritdoc} */ - public function getRegex() + public function getRegex() : string { return $this->calculation->getRegex(); } @@ -48,7 +48,7 @@ public function getRegex() /** * {@inheritdoc} */ - public function getFormat() + public function getFormat() : string { return $this->calculation->getFormat(); } @@ -56,7 +56,7 @@ public function getFormat() /** * {@inheritdoc} */ - public function getNumberOfDigits() + public function getNumberOfDigits() : int { return $this->calculation->getNumberOfDigits(); } @@ -64,7 +64,7 @@ public function getNumberOfDigits() /** * {@inheritdoc} */ - public function normalizeNumber($number) + public function normalizeNumber(string $number) : string { $this->defineStrategy($number); @@ -74,7 +74,7 @@ public function normalizeNumber($number) /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { return $this->calculation->extractBaseNumber($number); } @@ -82,7 +82,7 @@ public function extractBaseNumber($number) /** * {@inheritdoc} */ - public function extractCheckerDigit($number) + public function extractCheckerDigit(string $number) : string { return $this->calculation->extractCheckerDigit($number); } @@ -92,7 +92,7 @@ public function extractCheckerDigit($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_TO.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { return $this->calculation->calculateDigit($baseNumber); } @@ -102,7 +102,7 @@ public function calculateDigit($baseNumber) * * @param string $number Number of document. */ - private function defineStrategy($number) + private function defineStrategy(string $number) { $number = preg_replace('/\D/', '', $number); if (strlen($number) == 9) { diff --git a/src/StateRegistration/Tocantins/Eleven.php b/src/StateRegistration/Tocantins/Eleven.php index 0f34330..d62ba8c 100644 --- a/src/StateRegistration/Tocantins/Eleven.php +++ b/src/StateRegistration/Tocantins/Eleven.php @@ -24,7 +24,7 @@ public function __construct() /** * {@inheritdoc} */ - public function extractBaseNumber($number) + public function extractBaseNumber(string $number) : string { $baseNumber = parent::extractBaseNumber($number); @@ -36,7 +36,7 @@ public function extractBaseNumber($number) * * @see http://www.sintegra.gov.br/Cad_Estados/cad_TO.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); @@ -56,7 +56,7 @@ public function calculateDigit($baseNumber) * * @return string Returns base number without fixed digits. */ - private function removeFixedDigits($baseNumber) + private function removeFixedDigits(string $baseNumber) : string { return substr($baseNumber, 0, 2) . substr($baseNumber, 4); } diff --git a/src/StateRegistration/Tocantins/Nine.php b/src/StateRegistration/Tocantins/Nine.php index a3118d4..2dc1247 100644 --- a/src/StateRegistration/Tocantins/Nine.php +++ b/src/StateRegistration/Tocantins/Nine.php @@ -26,7 +26,7 @@ public function __construct() * * @see http://www.sintegra.gov.br/Cad_Estados/cad_TO.html */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $calculator = new DigitCalculator($baseNumber); $calculator->useComplementaryInsteadOfModule(); diff --git a/src/Voter.php b/src/Voter.php index 6240b20..5a34a3c 100644 --- a/src/Voter.php +++ b/src/Voter.php @@ -21,7 +21,7 @@ final class Voter extends AbstractDocument * @param string $section [optional] * @param string $zone [optional] */ - public function __construct($number, $section = null, $zone = null) + public function __construct(string $number, string $section = null, string $zone = null) { $number = preg_replace('/\D/', '', $number); parent::__construct($number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); @@ -30,7 +30,7 @@ public function __construct($number, $section = null, $zone = null) $this->zone = str_pad($zone, 3, '0', STR_PAD_LEFT); } - public static function createFromString($number, $section = null, $zone = null) + public static function createFromString(string $number, string $section = null, string $zone = null) { return parent::tryCreateFromString(self::class, $number, self::LENGTH, self::NUMBER_OF_DIGITS, self::LABEL); } @@ -40,7 +40,7 @@ public static function createFromString($number, $section = null, $zone = null) * * @return string Returns section. */ - public function getSection() + public function getSection() : string { return $this->section; } @@ -50,7 +50,7 @@ public function getSection() * * @return string Returns zone. */ - public function getZone() + public function getZone() : string { return $this->zone; } @@ -60,7 +60,7 @@ public function getZone() * * @return string Returns only numbers. */ - public function format() + public function format() : string { return "{$this}"; } @@ -68,7 +68,7 @@ public function format() /** * {@inheritdoc} */ - public function calculateDigit($baseNumber) + public function calculateDigit(string $baseNumber) : string { $firstDigit = $this->calculateFirstDigit($baseNumber); $secondDigit = $this->calculateSecondDigit("{$baseNumber}{$firstDigit}"); @@ -83,7 +83,7 @@ public function calculateDigit($baseNumber) * * @return string Returns the checker digit. */ - private function calculateFirstDigit($baseNumber) + private function calculateFirstDigit(string $baseNumber) : string { $calculator = new DigitCalculator(substr($baseNumber, 0, -2)); $calculator->withMultipliers([9, 8, 7, 6, 5, 4, 3, 2]); @@ -100,7 +100,7 @@ private function calculateFirstDigit($baseNumber) * * @return string Returns the checker digit. */ - private function calculateSecondDigit($baseNumber) + private function calculateSecondDigit(string $baseNumber) : string { $calculator = new DigitCalculator(substr($baseNumber, -3)); $calculator->withMultipliers([9, 8, 7]); diff --git a/tests/CnhTest.php b/tests/CnhTest.php index 2fb7113..d0ab911 100644 --- a/tests/CnhTest.php +++ b/tests/CnhTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnh; class CnhTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Cnh($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Cnh::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['83592802666'], @@ -24,14 +25,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['83592802666', '83592802666'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Cnh::LABEL, ''], @@ -40,7 +41,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Cnh::LABEL, 1], diff --git a/tests/CnpjTest.php b/tests/CnpjTest.php index a5f3f42..2c97ec5 100644 --- a/tests/CnpjTest.php +++ b/tests/CnpjTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; class CnpjTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Cnpj($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Cnpj::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['99999090910270'], @@ -24,7 +25,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['99999090910270', '99.999.090/9102-70'], @@ -32,7 +33,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Cnpj::LABEL, ''], @@ -41,7 +42,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Cnpj::LABEL, 1], diff --git a/tests/CnsTest.php b/tests/CnsTest.php index 7888204..1f03790 100644 --- a/tests/CnsTest.php +++ b/tests/CnsTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cns; class CnsTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Cns($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Cns::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['242912018460005'], @@ -30,14 +31,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['242912018460005', '242 9120 1846 0005'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Cns::LABEL, ''], @@ -46,7 +47,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Cns::LABEL, 1], diff --git a/tests/CpfTest.php b/tests/CpfTest.php index b4940b9..0844552 100644 --- a/tests/CpfTest.php +++ b/tests/CpfTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cpf; class CpfTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Cpf($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Cpf::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['06843273173'], @@ -24,7 +25,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['06843273173', '068.432.731-73'], @@ -32,7 +33,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Cpf::LABEL, ''], @@ -41,7 +42,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Cpf::LABEL, 1], diff --git a/tests/DigitCalculatorTest.php b/tests/DigitCalculatorTest.php index 8a208f7..a8c1918 100644 --- a/tests/DigitCalculatorTest.php +++ b/tests/DigitCalculatorTest.php @@ -60,7 +60,7 @@ public function testCalculateDigitForSaoPauloIdentityCard($number, $digit) $this->assertEquals($digit, $calculator->calculate()); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['3999100100001200000351202000003910476618602', '3'], diff --git a/tests/DocumentTestCase.php b/tests/DocumentTestCase.php index 01853e5..8b40adf 100644 --- a/tests/DocumentTestCase.php +++ b/tests/DocumentTestCase.php @@ -13,49 +13,49 @@ abstract class DocumentTestCase extends TestCase * * @return AbstractDocument */ - abstract public function createDocument($number); + abstract public function createDocument(string $number) : AbstractDocument; /** * @param string $number * * @return AbstractDocument|boolean */ - abstract public function createDocumentFromString($number); + abstract public function createDocumentFromString(string $number); /** * Provides a list of valid numbers * * @return array */ - abstract public function provideValidNumbers(); + abstract public function provideValidNumbers() : array; /** * Provides a list of valid numbers and its formats. * * @return array */ - abstract public function provideValidNumbersAndExpectedFormat(); + abstract public function provideValidNumbersAndExpectedFormat() : array; /** * Provides a empty data * * @return array */ - abstract public function provideEmptyData(); + abstract public function provideEmptyData() : array; /** * Provides a list of invalid numbers * * @return array */ - abstract public function provideInvalidNumber(); + abstract public function provideInvalidNumber() : array; /** * @param string $number * * @dataProvider provideValidNumbers */ - final public function testShouldCreateInstance($number) + final public function testShouldCreateInstance(string $number) { $document = $this->createDocument($number); $this->assertInstanceOf(AbstractDocument::class, $document); @@ -67,7 +67,7 @@ final public function testShouldCreateInstance($number) * * @dataProvider provideValidNumbers */ - final public function testShouldCreateInstanceFromString($number) + final public function testShouldCreateInstanceFromString(string $number) { $document = $this->createDocumentFromString($number); $this->assertInstanceOf(AbstractDocument::class, $document); @@ -80,7 +80,7 @@ final public function testShouldCreateInstanceFromString($number) * * @dataProvider provideValidNumbersAndExpectedFormat */ - final public function testShouldFormatDocument($number, $expectedFormat) + final public function testShouldFormatDocument(string $number, string $expectedFormat) { $document = $this->createDocument($number); $this->assertEquals($expectedFormat, $document->format()); @@ -92,44 +92,19 @@ final public function testShouldFormatDocument($number, $expectedFormat) * * @dataProvider provideValidNumbersAndExpectedFormat */ - final public function testShouldFormatDocumentFromString($number, $expectedFormat) + final public function testShouldFormatDocumentFromString(string $number, string $expectedFormat) { $document = $this->createDocumentFromString($number); $this->assertEquals($expectedFormat, $document->format()); } - /** - * @param string $documentType - * @param string $number - * - * @dataProvider provideEmptyData - */ - final public function testShouldThrowExceptionForEmptyData($documentType, $number) - { - $this->expectException(InvalidDocument::class); - $this->expectExceptionMessage("The {$documentType} must not be empty"); - $this->createDocument($number); - } - - /** - * @param string $documentType - * @param string $number - * - * @dataProvider provideEmptyData - */ - final public function testShouldReturnsFalseForEmptyData($documentType, $number) - { - $document = $this->createDocumentFromString($number); - $this->assertFalse($document, "Failed asserting that {$documentType} is not valid"); - } - /** * @param string $documentType * @param string $number * * @dataProvider provideInvalidNumber */ - public function testShouldThrowExceptionForInvalidNumbers($documentType, $number) + public function testShouldThrowExceptionForInvalidNumbers(string $documentType, string $number) { $numberSanitized = preg_replace('/[^\dX]/i', '', $number); $this->expectException(InvalidDocument::class); @@ -143,7 +118,7 @@ public function testShouldThrowExceptionForInvalidNumbers($documentType, $number * * @dataProvider provideInvalidNumber */ - public function testShouldReturnsFalseForInvalidNumbers($documentType, $number) + public function testShouldReturnsFalseForInvalidNumbers(string $documentType, string $number) { $document = $this->createDocumentFromString($number); $this->assertFalse($document, "Failed asserting that {$documentType} is not valid"); diff --git a/tests/JudiciaryProcessTest.php b/tests/JudiciaryProcessTest.php index 1e0bd03..ab45c6c 100644 --- a/tests/JudiciaryProcessTest.php +++ b/tests/JudiciaryProcessTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\JudiciaryProcess; class JudiciaryProcessTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new JudiciaryProcess($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return JudiciaryProcess::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['0048032.98.2009.8.09'], @@ -24,7 +25,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['0048032982009809', '0048032-98.2009.8.09.0000'], @@ -32,7 +33,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [JudiciaryProcess::LABEL, ''], @@ -41,7 +42,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [JudiciaryProcess::LABEL, 1], diff --git a/tests/PisPasepTest.php b/tests/PisPasepTest.php index f60bcd8..b94d59e 100644 --- a/tests/PisPasepTest.php +++ b/tests/PisPasepTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\PisPasep; class PisPasepTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new PisPasep($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return PisPasep::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['51823129491'], @@ -24,7 +25,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['51823129491', '518.23129.49-1'], @@ -32,7 +33,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [PisPasep::LABEL, ''], @@ -41,7 +42,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [PisPasep::LABEL, 1], diff --git a/tests/RenavamTest.php b/tests/RenavamTest.php index de4f9f9..104f07f 100644 --- a/tests/RenavamTest.php +++ b/tests/RenavamTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Renavam; class RenavamTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Renavam($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Renavam::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['61855253306'], @@ -25,14 +26,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['61855253306', '6185.525330-6'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Renavam::LABEL, ''], @@ -40,7 +41,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Renavam::LABEL, '00000000001'], diff --git a/tests/Sped/CTeOtherTest.php b/tests/Sped/CTeOtherTest.php index c7f0198..3981d8f 100644 --- a/tests/Sped/CTeOtherTest.php +++ b/tests/Sped/CTeOtherTest.php @@ -2,6 +2,7 @@ namespace Brazanation\Documents\Tests\Sped; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; use Brazanation\Documents\Sped\CTeOther; use Brazanation\Documents\Sped\EmissionType; @@ -9,31 +10,31 @@ class CTeOtherTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new CTeOther($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return CTeOther::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['52060433009911002506670120000007801267301613'], ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['52060433009911002506670120000007801267301613', '5206 0433 0099 1100 2506 6701 2000 0007 8012 6730 1613'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [CTeOther::LABEL, ''], @@ -42,7 +43,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [CTeOther::LABEL, str_pad('1', 44, 1)], @@ -58,7 +59,7 @@ public function provideInvalidNumber() ]; } - public function provideInvalidEmissionType() + public function provideInvalidEmissionType() : array { return [ [CTeOther::LABEL, '52060433009911002506550120000007801267301613'], diff --git a/tests/Sped/CTeTest.php b/tests/Sped/CTeTest.php index 19774d8..7a7f0ed 100644 --- a/tests/Sped/CTeTest.php +++ b/tests/Sped/CTeTest.php @@ -2,6 +2,7 @@ namespace Brazanation\Documents\Tests\Sped; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; use Brazanation\Documents\Sped\CTe; use Brazanation\Documents\Sped\EmissionType; @@ -9,31 +10,31 @@ class CTeTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new CTe($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return CTe::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['52060433009911002506570120000007801267301610'], ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['52060433009911002506570120000007801267301610', '5206 0433 0099 1100 2506 5701 2000 0007 8012 6730 1610'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [CTe::LABEL, ''], @@ -42,7 +43,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [CTe::LABEL, str_pad('1', 44, 1)], @@ -58,7 +59,7 @@ public function provideInvalidNumber() ]; } - public function provideInvalidEmissionType() + public function provideInvalidEmissionType() : array { return [ [CTe::LABEL, '52060433009911002506550120000007801267301613'], diff --git a/tests/Sped/MDFeTest.php b/tests/Sped/MDFeTest.php index edcd20e..a77cc81 100644 --- a/tests/Sped/MDFeTest.php +++ b/tests/Sped/MDFeTest.php @@ -2,6 +2,7 @@ namespace Brazanation\Documents\Tests\Sped; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; use Brazanation\Documents\Sped\EmissionType; use Brazanation\Documents\Sped\MDFe; @@ -9,31 +10,31 @@ class MDFeTest extends TestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new MDFe($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return MDFe::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['52060433009911002506580120000007801267301614'], ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['52060433009911002506580120000007801267301614', '5206 0433 0099 1100 2506 5801 2000 0007 8012 6730 1614'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [MDFe::LABEL, ''], @@ -42,7 +43,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [MDFe::LABEL, str_pad('1', 44, 1)], @@ -58,7 +59,7 @@ public function provideInvalidNumber() ]; } - public function provideInvalidEmissionType() + public function provideInvalidEmissionType() : array { return [ [MDFe::LABEL, '52060433009911002506550120000007801267301613'], diff --git a/tests/Sped/NFCeTest.php b/tests/Sped/NFCeTest.php index ffc6c6e..32944dc 100644 --- a/tests/Sped/NFCeTest.php +++ b/tests/Sped/NFCeTest.php @@ -2,6 +2,7 @@ namespace Brazanation\Documents\Tests\Sped; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; use Brazanation\Documents\Sped\EmissionType; use Brazanation\Documents\Sped\NFCe; @@ -9,31 +10,31 @@ class NFCeTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new NFCe($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return NFCe::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['52060433009911002506650120000007802067301610'], ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['52060433009911002506650120000007802067301610', '5206 0433 0099 1100 2506 6501 2000 0007 8020 6730 1610'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [NFCe::LABEL, ''], @@ -42,7 +43,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [NFCe::LABEL, str_pad('1', 44, 1)], @@ -58,7 +59,7 @@ public function provideInvalidNumber() ]; } - public function provideInvalidEmissionType() + public function provideInvalidEmissionType() : array { return [ [NFCe::LABEL, '52060433009911002506550120000007801267301613'], diff --git a/tests/Sped/NFeTest.php b/tests/Sped/NFeTest.php index 57a4e01..cf92c44 100644 --- a/tests/Sped/NFeTest.php +++ b/tests/Sped/NFeTest.php @@ -2,6 +2,7 @@ namespace Brazanation\Documents\Tests\Sped; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Cnpj; use Brazanation\Documents\Sped\EmissionType; use Brazanation\Documents\Sped\NFe; @@ -9,17 +10,17 @@ class NFeTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new NFe($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return NFe::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['52060433009911002506550120000007801267301613'], @@ -28,14 +29,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['52060433009911002506550120000007801267301613', '5206 0433 0099 1100 2506 5501 2000 0007 8012 6730 1613'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [NFe::LABEL, ''], @@ -44,7 +45,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [NFe::LABEL, str_pad('1', 44, 1)], @@ -60,7 +61,7 @@ public function provideInvalidNumber() ]; } - public function provideInvalidEmissionType() + public function provideInvalidEmissionType() : array { return [ [NFe::LABEL, '52060433009911002506650120000007802067301610'], diff --git a/tests/StateRegistration/AcreTest.php b/tests/StateRegistration/AcreTest.php index 926884d..1a224ad 100644 --- a/tests/StateRegistration/AcreTest.php +++ b/tests/StateRegistration/AcreTest.php @@ -2,37 +2,38 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Acre; use Brazanation\Documents\Tests\DocumentTestCase; class AcreTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return StateRegistration::AC($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Acre::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ 'AC' => ['0100482300112'], ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['0100482300112', '01.004.823/001-12'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Acre::LONG_NAME, ''], @@ -41,7 +42,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Acre::LONG_NAME, 1], diff --git a/tests/StateRegistration/AlagoasTest.php b/tests/StateRegistration/AlagoasTest.php index f86d4c4..607379f 100644 --- a/tests/StateRegistration/AlagoasTest.php +++ b/tests/StateRegistration/AlagoasTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Alagoas; use Brazanation\Documents\Tests\DocumentTestCase; class AlagoasTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return StateRegistration::AL($number); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Alagoas::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['240000048'], @@ -29,7 +30,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['240000048', '24.000.004-8'], @@ -40,14 +41,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Alagoas::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Alagoas::LONG_NAME, 1], diff --git a/tests/StateRegistration/AmapaTest.php b/tests/StateRegistration/AmapaTest.php index 8535c10..9571d96 100644 --- a/tests/StateRegistration/AmapaTest.php +++ b/tests/StateRegistration/AmapaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Amapa; use Brazanation\Documents\Tests\DocumentTestCase; class AmapaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Amapa()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Amapa::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['03.012.345-9'], @@ -26,21 +27,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['030123459', '03.012.345-9'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Amapa::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Amapa::LONG_NAME, 1], diff --git a/tests/StateRegistration/AmazonasTest.php b/tests/StateRegistration/AmazonasTest.php index 5545fd2..b82080e 100644 --- a/tests/StateRegistration/AmazonasTest.php +++ b/tests/StateRegistration/AmazonasTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Amazonas; use Brazanation\Documents\Tests\DocumentTestCase; class AmazonasTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Amazonas()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Amazonas::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['04.345.678-2'], @@ -29,21 +30,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['04.345.678-2', '04.345.678-2'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Amazonas::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Amazonas::LONG_NAME, 1], diff --git a/tests/StateRegistration/BahiaTest.php b/tests/StateRegistration/BahiaTest.php index 4224ae9..d8fa066 100644 --- a/tests/StateRegistration/BahiaTest.php +++ b/tests/StateRegistration/BahiaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Bahia; use Brazanation\Documents\Tests\DocumentTestCase; class BahiaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Bahia()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Bahia::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['123456-63'], @@ -37,7 +38,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['123456-63', '0123456-63'], @@ -45,14 +46,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Bahia::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Bahia::LONG_NAME, '000000001'], diff --git a/tests/StateRegistration/CearaTest.php b/tests/StateRegistration/CearaTest.php index d172508..79834db 100644 --- a/tests/StateRegistration/CearaTest.php +++ b/tests/StateRegistration/CearaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Ceara; use Brazanation\Documents\Tests\DocumentTestCase; class CearaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Ceara()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Ceara::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['06.998.161-2'], @@ -28,7 +29,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['06.998.161-2', '06.998.161-2'], @@ -36,14 +37,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Ceara::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Ceara::LONG_NAME, '1'], diff --git a/tests/StateRegistration/DistritoFederalTest.php b/tests/StateRegistration/DistritoFederalTest.php index 21dda7d..bb0da92 100644 --- a/tests/StateRegistration/DistritoFederalTest.php +++ b/tests/StateRegistration/DistritoFederalTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\DistritoFederal as DF; use Brazanation\Documents\Tests\DocumentTestCase; class DistritoFederalTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new DF()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, DF::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['0714880000168'], @@ -28,7 +29,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['0756855500115', '07.568555.001-15'], @@ -37,7 +38,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [DF::LONG_NAME, ''], @@ -46,7 +47,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [DF::LONG_NAME, 1], diff --git a/tests/StateRegistration/EspiritoSantoTest.php b/tests/StateRegistration/EspiritoSantoTest.php index 638db16..5acd71a 100644 --- a/tests/StateRegistration/EspiritoSantoTest.php +++ b/tests/StateRegistration/EspiritoSantoTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\EspiritoSanto; use Brazanation\Documents\Tests\DocumentTestCase; class EspiritoSantoTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new EspiritoSanto()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, EspiritoSanto::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['082260664'], @@ -31,21 +32,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['082260664', '082.260.66-4'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [EspiritoSanto::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [EspiritoSanto::LONG_NAME, '1'], diff --git a/tests/StateRegistration/GoiasTest.php b/tests/StateRegistration/GoiasTest.php index 562c189..36e980b 100644 --- a/tests/StateRegistration/GoiasTest.php +++ b/tests/StateRegistration/GoiasTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Goias; use Brazanation\Documents\Tests\DocumentTestCase; class GoiasTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Goias()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Goias::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['110944020'], @@ -27,21 +28,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['109876547','10.987.654-7'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Goias::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Goias::LONG_NAME, '1'], diff --git a/tests/StateRegistration/MaranhaoTest.php b/tests/StateRegistration/MaranhaoTest.php index 4e00c57..a5345cb 100644 --- a/tests/StateRegistration/MaranhaoTest.php +++ b/tests/StateRegistration/MaranhaoTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Maranhao; use Brazanation\Documents\Tests\DocumentTestCase; class MaranhaoTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Maranhao()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Maranhao::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['12.074072-9'], @@ -26,21 +27,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['120000385','12.000.038-5'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Maranhao::LONG_NAME, 0], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Maranhao::LONG_NAME, '1'], diff --git a/tests/StateRegistration/MatoGrossoSulTest.php b/tests/StateRegistration/MatoGrossoSulTest.php index f3a43f9..02ecf16 100644 --- a/tests/StateRegistration/MatoGrossoSulTest.php +++ b/tests/StateRegistration/MatoGrossoSulTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\MatoGrossoSul; use Brazanation\Documents\Tests\DocumentTestCase; class MatoGrossoSulTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new MatoGrossoSul()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, MatoGrossoSul::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['28.322.235-2'], @@ -38,14 +39,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['283222352', '28.322.235-2'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [MatoGrossoSul::LONG_NAME, 0], @@ -54,7 +55,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [MatoGrossoSul::LONG_NAME, 1], diff --git a/tests/StateRegistration/MatoGrossoTest.php b/tests/StateRegistration/MatoGrossoTest.php index 5c9dd73..87b8280 100644 --- a/tests/StateRegistration/MatoGrossoTest.php +++ b/tests/StateRegistration/MatoGrossoTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\MatoGrosso; use Brazanation\Documents\Tests\DocumentTestCase; class MatoGrossoTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new MatoGrosso()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, MatoGrosso::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['0013193686-7'], @@ -113,7 +114,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['00131936867', '0013193686-7'], @@ -123,7 +124,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [MatoGrosso::LONG_NAME, 0], @@ -132,7 +133,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [MatoGrosso::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/MinasGeraisTest.php b/tests/StateRegistration/MinasGeraisTest.php index c4c8dae..e83e3ec 100644 --- a/tests/StateRegistration/MinasGeraisTest.php +++ b/tests/StateRegistration/MinasGeraisTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\MinasGerais as MG; use Brazanation\Documents\Tests\DocumentTestCase; class MinasGeraisTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new MG()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, MG::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['062.307.904/0081'], @@ -28,7 +29,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['2080189746429', '208.018.974/6429'], @@ -36,7 +37,7 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [MG::LONG_NAME, 0], @@ -45,7 +46,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [MG::LONG_NAME, 1], diff --git a/tests/StateRegistration/ParaTest.php b/tests/StateRegistration/ParaTest.php index d742667..2f1cc63 100644 --- a/tests/StateRegistration/ParaTest.php +++ b/tests/StateRegistration/ParaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Para; use Brazanation\Documents\Tests\DocumentTestCase; class ParaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Para()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Para::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['15.229.851-7'], @@ -34,21 +35,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['152298517', '15.229.851-7'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Para::LONG_NAME, null], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Para::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/ParaibaTest.php b/tests/StateRegistration/ParaibaTest.php index cc7d661..e27265a 100644 --- a/tests/StateRegistration/ParaibaTest.php +++ b/tests/StateRegistration/ParaibaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Paraiba; use Brazanation\Documents\Tests\DocumentTestCase; class ParaibaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Paraiba()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Paraiba::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['16.030.321-4'], @@ -125,21 +126,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['317806734', '31.780.673-4'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Paraiba::LONG_NAME, null], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Paraiba::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/ParanaTest.php b/tests/StateRegistration/ParanaTest.php index 490028d..b182076 100644 --- a/tests/StateRegistration/ParanaTest.php +++ b/tests/StateRegistration/ParanaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Parana; use Brazanation\Documents\Tests\DocumentTestCase; class ParanaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Parana()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Parana::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['099.00004-09'], @@ -35,21 +36,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['9025821693', '902.58216-93'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Parana::LONG_NAME, null], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Parana::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/PernambucoTest.php b/tests/StateRegistration/PernambucoTest.php index 496085d..95b9441 100644 --- a/tests/StateRegistration/PernambucoTest.php +++ b/tests/StateRegistration/PernambucoTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Pernambuco; use Brazanation\Documents\Tests\DocumentTestCase; class PernambucoTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Pernambuco()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Pernambuco::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['18.1.001.0000004-9'], @@ -31,7 +32,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['18100100000049', '18.1.001.0000004-9'], @@ -39,14 +40,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Pernambuco::LONG_NAME, null], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Pernambuco::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/PiauiTest.php b/tests/StateRegistration/PiauiTest.php index c9a5be5..e315ec3 100644 --- a/tests/StateRegistration/PiauiTest.php +++ b/tests/StateRegistration/PiauiTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Piaui; use Brazanation\Documents\Tests\DocumentTestCase; class PiauiTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Piaui()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Piaui::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['193016567'], @@ -27,21 +28,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['193016567', '19.301.656-7'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Piaui::LONG_NAME, null], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Piaui::LONG_NAME, '11111111111'], diff --git a/tests/StateRegistration/RioDeJaneiroTest.php b/tests/StateRegistration/RioDeJaneiroTest.php index 82b2722..c4afad1 100644 --- a/tests/StateRegistration/RioDeJaneiroTest.php +++ b/tests/StateRegistration/RioDeJaneiroTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\RioDeJaneiro; use Brazanation\Documents\Tests\DocumentTestCase; class RioDeJaneiroTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new RioDeJaneiro()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, RioDeJaneiro::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['53.518.028'], @@ -26,14 +27,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['53518028', '53.518.028'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [RioDeJaneiro::LONG_NAME, null], @@ -42,7 +43,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [RioDeJaneiro::LONG_NAME, '11111111'], diff --git a/tests/StateRegistration/RioGrandeDoNorteTest.php b/tests/StateRegistration/RioGrandeDoNorteTest.php index dc8f304..2eb492a 100644 --- a/tests/StateRegistration/RioGrandeDoNorteTest.php +++ b/tests/StateRegistration/RioGrandeDoNorteTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\RioGrandeDoNorte; use Brazanation\Documents\Tests\DocumentTestCase; class RioGrandeDoNorteTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new RioGrandeDoNorte()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, RioGrandeDoNorte::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['20.040.040-1'], @@ -32,7 +33,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['200400401', '20.040.040-1'], @@ -41,14 +42,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [RioGrandeDoNorte::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [RioGrandeDoNorte::LONG_NAME, '11111111'], diff --git a/tests/StateRegistration/RioGrandeDoSulTest.php b/tests/StateRegistration/RioGrandeDoSulTest.php index bd3094b..d23e27c 100644 --- a/tests/StateRegistration/RioGrandeDoSulTest.php +++ b/tests/StateRegistration/RioGrandeDoSulTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\RioGrandeDoSul; use Brazanation\Documents\Tests\DocumentTestCase; class RioGrandeDoSulTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new RioGrandeDoSul()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, RioGrandeDoSul::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['050/0068836'], @@ -27,21 +28,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['0500068836', '050/0068836'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [RioGrandeDoSul::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [RioGrandeDoSul::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/RondoniaTest.php b/tests/StateRegistration/RondoniaTest.php index 44654ae..985ff99 100644 --- a/tests/StateRegistration/RondoniaTest.php +++ b/tests/StateRegistration/RondoniaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Rondonia; use Brazanation\Documents\Tests\DocumentTestCase; class RondoniaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Rondonia()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Rondonia::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['0000000172159-3'], @@ -52,21 +53,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['00000001721593', '0000000172159-3'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Rondonia::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Rondonia::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/RoraimaTest.php b/tests/StateRegistration/RoraimaTest.php index 2a4a508..33974cd 100644 --- a/tests/StateRegistration/RoraimaTest.php +++ b/tests/StateRegistration/RoraimaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Roraima; use Brazanation\Documents\Tests\DocumentTestCase; class RoraimaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Roraima()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Roraima::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['24006628-1'], @@ -35,21 +36,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['240066281', '24006628-1'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Roraima::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Roraima::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/SantaCatarinaTest.php b/tests/StateRegistration/SantaCatarinaTest.php index 8ecd895..c6be73f 100644 --- a/tests/StateRegistration/SantaCatarinaTest.php +++ b/tests/StateRegistration/SantaCatarinaTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\SantaCatarina; use Brazanation\Documents\Tests\DocumentTestCase; class SantaCatarinaTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new SantaCatarina()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, SantaCatarina::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['251040852'], @@ -27,21 +28,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['251040852','251.040.852'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [SantaCatarina::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [SantaCatarina::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/SaoPauloTest.php b/tests/StateRegistration/SaoPauloTest.php index 7853bf6..0ca9d13 100644 --- a/tests/StateRegistration/SaoPauloTest.php +++ b/tests/StateRegistration/SaoPauloTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\SaoPaulo; use Brazanation\Documents\Tests\DocumentTestCase; class SaoPauloTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new SaoPaulo()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, SaoPaulo::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ 'commercial-industrial' => ['110.042.490.114'], @@ -26,7 +27,7 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ 'commercial-industrial' => ['110042490114', '110.042.490.114'], @@ -34,14 +35,14 @@ public function provideValidNumbersAndExpectedFormat() ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [SaoPaulo::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [SaoPaulo::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/SergipeTest.php b/tests/StateRegistration/SergipeTest.php index f1d177e..5cbd41d 100644 --- a/tests/StateRegistration/SergipeTest.php +++ b/tests/StateRegistration/SergipeTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Sergipe; use Brazanation\Documents\Tests\DocumentTestCase; class SergipeTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Sergipe()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Sergipe::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['44.250.767-4'], @@ -26,21 +27,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['442507674', '44.250.767-4'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Sergipe::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Sergipe::LONG_NAME, '1111111111'], diff --git a/tests/StateRegistration/TocantinsTest.php b/tests/StateRegistration/TocantinsTest.php index 341696c..da7e230 100644 --- a/tests/StateRegistration/TocantinsTest.php +++ b/tests/StateRegistration/TocantinsTest.php @@ -2,23 +2,24 @@ namespace Brazanation\Documents\Tests\StateRegistration; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\StateRegistration; use Brazanation\Documents\StateRegistration\Tocantins; use Brazanation\Documents\Tests\DocumentTestCase; class TocantinsTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new StateRegistration($number, new Tocantins()); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return StateRegistration::createFromString($number, Tocantins::SHORT_NAME); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ ['29010227836'], @@ -30,21 +31,21 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['29010227836', '29.01.022.783-6'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Tocantins::LONG_NAME, ''], ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Tocantins::LONG_NAME, '1111111111'], diff --git a/tests/VoterTest.php b/tests/VoterTest.php index 0ff8658..3017dda 100644 --- a/tests/VoterTest.php +++ b/tests/VoterTest.php @@ -2,21 +2,22 @@ namespace Brazanation\Documents\Tests; +use Brazanation\Documents\AbstractDocument; use Brazanation\Documents\Voter; class VoterTest extends DocumentTestCase { - public function createDocument($number) + public function createDocument(string $number) : AbstractDocument { return new Voter($number, null, null); } - public function createDocumentFromString($number) + public function createDocumentFromString(string $number) { return Voter::createFromString($number); } - public function provideValidNumbers() + public function provideValidNumbers() : array { return [ 'GO' => ['247003181023'], @@ -28,14 +29,14 @@ public function provideValidNumbers() ]; } - public function provideValidNumbersAndExpectedFormat() + public function provideValidNumbersAndExpectedFormat() : array { return [ ['106644440302', '106644440302'], ]; } - public function provideEmptyData() + public function provideEmptyData() : array { return [ [Voter::LABEL, ''], @@ -44,7 +45,7 @@ public function provideEmptyData() ]; } - public function provideInvalidNumber() + public function provideInvalidNumber() : array { return [ [Voter::LABEL, 1],