Skip to content

Commit

Permalink
Merge pull request #6 from lsnepomuceno/feature/adds-ibge-info-cep-en…
Browse files Browse the repository at this point in the history
…tity-php-83-remove-cep-la-provider

Feature/adds ibge info cep entity php 83 remove cep la provider
  • Loading branch information
lsnepomuceno authored Jan 12, 2024
2 parents ed17142 + 183be59 commit c815473
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/action_pr_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.1', '8.2' ]
php-versions: [ '8.1', '8.2', '8.3' ]
env:
extensions: mbstring, dom, fileinfo, openssl, json, imagick, swoole, sqlite3
key: cache-v5
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^8.1 || ^8.2",
"php": "^8.1 || ^8.2 || ^8.3",
"ext-json": "*",
"ext-fileinfo": "*",
"ext-mbstring": "*",
Expand Down
51 changes: 0 additions & 51 deletions src/CepProviders/CepLa.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/CepProviders/OpenCep.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function get(string $cep): ?CepEntity
street : $data->logradouro,
state : States::get($data->uf),
uf : $data->uf,
neighborhood: $data->bairro
neighborhood: $data->bairro,
ibge : $data->ibge
);
} catch (Exception $e) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/CepProviders/Postomon.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public function get(string $cep): ?CepEntity
street : $data->logradouro,
state : States::get($data->estado),
uf : $data->estado,
neighborhood: $data->bairro
neighborhood: $data->bairro,
ibge : $data->cidade_info?->codigo_ibge
);
} catch (Exception $e) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/CepProviders/ViaCep.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function get(string $cep): ?CepEntity
street : $data->logradouro,
state : States::get($data->uf),
uf : $data->uf,
neighborhood: $data->bairro
neighborhood: $data->bairro,
ibge : $data->ibge
);
} catch (Exception $e) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/Entities/CepEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function __construct(
public string $uf,
public string $neighborhood,
public string|int|null $number = null,
public ?string $complement = null
public ?string $complement = null,
public string|int|null $ibge = null
)
{
}
Expand Down
2 changes: 0 additions & 2 deletions src/Services/CepService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\ApiCep;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\BrasilApiV1;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\BrasilApiV2;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\CepLa;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\OpenCep;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\Pagarme;
use LSNepomuceno\LaravelBrazilianCeps\CepProviders\Postomon;
Expand All @@ -28,7 +27,6 @@ public function __construct(
Pagarme::class,
OpenCep::class,
ApiCep::class,
CepLa::class,
Postomon::class,
BrasilApiV1::class,
BrasilApiV2::class
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/ApiCepProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public function testValidatesIfTheRequestWillBeExecutedSuccessfully()
$apiCepProvider = new ApiCep();
$response = $apiCepProvider->get($cep);

if (!$response) {
$this->markTestSkipped(
'APICep provider unavailable.'
);
}

$requiredFields = DefaultValues::successfullyRequiredFields();
$optionalFields = DefaultValues::optionalFields();

Expand Down
83 changes: 0 additions & 83 deletions tests/Feature/CepLaProviderTest.php

This file was deleted.

3 changes: 2 additions & 1 deletion tests/Helpers/DefaultValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static function optionalFields(): array
{
return [
'number',
'complement'
'complement',
'ibge'
];
}
}
9 changes: 6 additions & 3 deletions tests/Unit/CepEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function testValidatesCepEntityStructure()
uf : 'uf',
neighborhood: 'neighborhood',
number : 'number',
complement : 'complement'
complement : 'complement',
ibge : 'ibge'
);

$this->assertIsArray($cepEntity->toArray());
Expand All @@ -33,7 +34,8 @@ public function testValidatesCepEntityStructureWithIntegerNumber()
uf : 'uf',
neighborhood: 'neighborhood',
number : 1000,
complement : 'complement'
complement : 'complement',
ibge : 'ibge'
);

$this->assertIsArray($cepEntity->toArray());
Expand All @@ -49,7 +51,8 @@ public function testValidatesCepEntityStructureWhenComplementAndNumberAreNull()
uf : 'uf',
neighborhood: 'neighborhood',
number : null,
complement : null
complement : null,
ibge : null
);

$this->assertIsArray($cepEntity->toArray());
Expand Down

0 comments on commit c815473

Please sign in to comment.