Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
fulviocanducci committed Dec 12, 2024
1 parent 8042fa3 commit 53f5777
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 15 deletions.
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
}
],
"require": {
"php": ">=7.2.7",
"php-extended/php-simple-cache-filesystem": "^3.1"
"php": ">=8.3.2",
"php-extended/php-simple-cache-filesystem": "^7.0",
"php-extended/php-file-object": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "8.5.2",
"phpspec/phpspec": "6.1.1"
"phpunit/phpunit": "8.5.41",
"phpspec/phpspec": "7.5.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 3 additions & 1 deletion src/Canducci/ZipCode/Providers/ZipCodeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function register()
$this->app->singleton(
'PhpExtended\SimpleCache\SimpleCacheFilesystem',
function ($app) {
return new \PhpExtended\SimpleCache\SimpleCacheFilesystem(config('simplecache.path') ?? __DIR__);
$path = config('simplecache.path') ?? __DIR__;
$fileSystem = new \PhpExtended\File\FileSystem($path);
return new \PhpExtended\SimpleCache\SimpleCacheFilesystem($fileSystem);
}
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Canducci/ZipCode/ZipCodeAddressInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ public function getZipCodeItem(): array
$ret['ibge'],
$ret['gia'],
$ret['ddd'],
$ret['siafi']
$ret['siafi'],
$ret['unidade'],
$ret['estado'],
$ret['regiao']
);
}
return $array;
Expand Down
4 changes: 2 additions & 2 deletions src/Canducci/ZipCode/ZipCodeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function zipcode($value, $renew = false)
{
if (function_exists('app')) {
$zip_code = app('Canducci\ZipCode\Contracts\ZipCodeContract');
} else {
$cache = new \PhpExtended\SimpleCache\SimpleCacheFilesystem("./tests/tmp");
} else {
$cache = new \PhpExtended\SimpleCache\SimpleCacheFilesystem(new PhpExtended\File\FileSystem("./tests/tmp"));
$request = new \Canducci\ZipCode\ZipCodeRequest();
$zip_code = new \Canducci\ZipCode\ZipCode($cache, $request);
}
Expand Down
37 changes: 35 additions & 2 deletions src/Canducci/ZipCode/ZipCodeItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class ZipCodeItem
protected $gia;
protected $ddd;
protected $siafi;
protected $unidade;
protected $estado;
protected $regiao;

/**
* ZipCodeItem constructor.
Expand All @@ -30,10 +33,13 @@ class ZipCodeItem
* @param $uf
* @param $ibge
* @param $gia
* @param $dddd
* @param $ddd
* @param @siafi
* @param $unidade
* @param $estado
* @param @regiao
*/
public function __construct($cep, $logradouro, $complemento, $bairro, $localidade, $uf, $ibge, $gia, $ddd, $siafi)
public function __construct($cep, $logradouro, $complemento, $bairro, $localidade, $uf, $ibge, $gia, $ddd, $siafi, $unidade, $estado, $regiao)
{
$this->cep = $cep;
$this->logradouro = $logradouro;
Expand All @@ -45,6 +51,9 @@ public function __construct($cep, $logradouro, $complemento, $bairro, $localidad
$this->gia = $gia;
$this->ddd = $ddd;
$this->siafi = $siafi;
$this->unidade = $unidade;
$this->estado = $estado;
$this->regiao = $regiao;
}

/**
Expand Down Expand Up @@ -127,6 +136,30 @@ public function getSiafi(): string
return $this->siafi;
}

/**
* @return mixed
*/
public function getUnidade(): string
{
return $this->unidade;
}

/**
* @return mixed
*/
public function getEstado(): string
{
return $this->estado;
}

/**
* @return mixed
*/
public function getRegiao(): string
{
return $this->regiao;
}

/**
* @param $name
* @return mixed
Expand Down
11 changes: 6 additions & 5 deletions tests/ZipCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Canducci\ZipCode\ZipCodeTrait;
use PhpExtended\SimpleCache\SimpleCacheFilesystem;
use PHPUnit\Framework\TestCase;
use PhpExtended\File\FileSystem;

class ZipCodeTest extends TestCase
{
Expand All @@ -31,7 +32,7 @@ public function setZipCodeInstance(): void
}
$path = realpath(__DIR__ . '/tmp');
$this->zipCode = new ZipCode(
new SimpleCacheFilesystem($path),
new SimpleCacheFilesystem(new Filesystem($path)),
new ZipCodeRequest()
);
}
Expand Down Expand Up @@ -72,14 +73,14 @@ public function testZipCodeInfoTestMethods(): void

public function testZipCodeAddressInfo(): void
{
$zipCodeAddressInfo = $this->address->find('sp', 'são paulo', 'ave');
$zipCodeAddressInfo = $this->address->find('sp', 'paulo', 'ave');
$this->assertNotNull($zipCodeAddressInfo);
$this->assertInstanceOf(ZipCodeAddressInfo::class, $zipCodeAddressInfo);
}

public function testZipCodeAddressInfoTestMethods(): void
{
$zipCodeAddressInfo = $this->address->find('sp', 'são paulo', 'ave');
$zipCodeAddressInfo = $this->address->find('sp', 'paulo', 'ave');
$this->assertNotNull($zipCodeAddressInfo);
$this->assertIsString($zipCodeAddressInfo->getJson());
$this->assertIsArray($zipCodeAddressInfo->getArray());
Expand All @@ -97,7 +98,7 @@ public function testZipCodeReturnCep(): void

public function testZipCodeAddressReturnCeps(): void
{
$zipCodeAddressInfo = $this->address->find('sp', 'são paulo', 'ave');
$zipCodeAddressInfo = $this->address->find('sp', 'paulo', 'ave');
$datas = $zipCodeAddressInfo->getArray();
$this->assertIsArray($datas);
$this->assertEquals(50, $zipCodeAddressInfo->count());
Expand All @@ -106,7 +107,7 @@ public function testZipCodeAddressReturnCeps(): void

public function testZipCodeAddressTestKeys(): void
{
$zipCodeAddressInfo = $this->address->find('sp', 'são paulo', 'ave');
$zipCodeAddressInfo = $this->address->find('sp', 'paulo', 'ave');
$datas = $zipCodeAddressInfo->getArray();
$this->assertArrayHasKey('cep', $datas[0]);
$this->assertArrayHasKey('logradouro', $datas[0]);
Expand Down

0 comments on commit 53f5777

Please sign in to comment.