php-extended / php-api-fr-insee-cog-object
A library that implements the php-api-fr-insee-cog-interface library
Requires
Requires (Dev)
- dev-master
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.2.3
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.7
- 6.1.6
- 6.1.5
- 6.1.4
- 6.1.3
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.0
- 5.0.1
- 5.0.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.6.1
- 3.6.0
- 3.5.0
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
This package is auto-updated.
Last update: 2024-12-01 00:16:42 UTC
README
A library that implements the php-api-fr-insee-cog-interface library.
This library makes insee Official Geographic Code (COG) available as objects to populate a database. The COG is available at the url : https://www.insee.fr/fr/information/2560452.
Last Updated Date : 2020-09-27
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-api-fr-insee-cog-object ^7
Basic Usage
This library gives an unique endpoint : \PhpExtended\Insee\InseeCogEndpoint
from which all data can be retrieved.
- For retrieving pays, you may use :
$endpoint = new InseeCogEndpoint();
$paysIterator = $endpoint->getPaysIterator($endpoint->getMaximumAvailableYear());
foreach($paysIterator as $pays)
{
// @var $pays \PhpExtended\Insee\InseeCogPaysInterface
}
If you want all the pays by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getPaysIterator($year) as $pays)
{
// @var $pays \PhpExtended\Insee\InseeCogPaysInterface
}
}
- For retrieving regions, you may use :
$endpoint = new InseeCogEndpoint();
$regionIterator = $endpoint->getRegionIterator($endpoint->getMaximumAvailableYear());
foreach($regionIterator as $region)
{
// @var $region \PhpExtended\Insee\InseeCogRegionInterface
}
If you want all the regions by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getRegionIterator($year) as $region)
{
// @var $region \PhpExtended\Insee\InseeCogRegionInterface
}
}
- For retrieving departements, you may use :
$endpoint = new InseeCogEndpoint();
$departementIterator = $endpoint->getDepartementIterator($endpoint->getMaximumAvailableYear());
foreach($departementIterator as $departement)
{
// @var $departement \PhpExtended\Insee\InseeCogDepartementInterface
}
If you want all the departements by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getDepartementIterator($year) as $departement)
{
// @var $departement \PhpExtended\Insee\InseeCogDepartementInterface
}
}
- For retrieving arrondissements, you may use :
$endpoint = new InseeCogEndpoint();
$arrondissementIterator = $endpoint->getArrondissementIterator($endpoint->getMaximumAvailableYear());
foreach($arrondissementIterator as $arrondissement)
{
// @var $arrondissement \PhpExtended\Insee\InseeCogArrondissementInterface
}
If you want all the arrondissements by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getArrondissementIterator($year) as $arrondissement)
{
// @var $arrondissement \PhpExtended\Insee\InseeCogArrondissementInterface
}
}
- For retrieving cantons, you may use :
$endpoint = new InseeCogEndpoint();
$cantonIterator = $endpoint->getCantonIterator($endpoint->getMaximumAvailableYear());
foreach($cantonIterator as $canton)
{
// @var $canton \PhpExtended\Insee\InseeCogCantonInterface
}
If you want all the cantons by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getCantonIterator($year) as $canton)
{
// @var $canton \PhpExtended\Insee\InseeCogCantonInterface
}
}
- For retrieving communes, you may use :
$endpoint = new InseeCogEndpoint();
$communeIterator = $endpoint->getCommuneIterator($endpoint->getMaximumAvailableYear());
foreach($communeIterator as $commune)
{
// @var $commune \PhpExtended\Insee\InseeCogCommuneInterface
}
If you want all the communes by year, do :
$endpoint = new InseeCogEndpoint();
foreach($year = $endpoint->getMinimumAvailableYear(); $year <= $endpoint->getMaximumAvailableYear(); $year++)
{
foreach($endpoint->getCommuneIterator($year) as $commune)
{
// @var $commune \PhpExtended\Insee\InseeCogCommuneInterface
}
}
- For retrieving commune events, you may use :
$endpoint = new InseeCogEndpoint();
foreach($endpoint->getEventCommuneIterator($year) as $event)
{
// @var $event \PhpExtended\Insee\InseeCogEventCommuneInterface
}
License
The code is under MIT (See license file).