Appearance
Dataset
php
final class StanislasPoisson\FrenchPostalCode\Core\DatasetReads the data files shipped with the package, without any framework.
Each table is a CSV file with a header. An empty value is read as null. The manifest announces the columns and the number of rows of every file, and the reader checks them: a truncated or altered file is an error, not a silent partial load.
Source: src/Core/Dataset.php
Constants
| Name | Value | Description |
|---|---|---|
TABLES | ['regions', 'departments', 'communes', 'cities', 'commune_successions'] | The tables, in the order they must be loaded: a table comes after the tables it refers to. |
Methods
__construct()
php
public function __construct(string $directory = …, string $schemas = …)chunks()
php
public function chunks(string $table, int $size = 1000): GeneratorThe rows of a table, in blocks, for the loaders that write them in several statements.
Returns Generator<int, list<array<string, string|null>>>
columns()
php
public function columns(string $table): arrayReturns list<string>
count()
php
public function count(string $table): intmanifest()
php
public function manifest(): arrayThe versions of the sources the data was built from, and the date of the export.
Returns Manifest
path()
php
public function path(string $table): stringrows()
php
public function rows(string $table): GeneratorThe rows of a table, one at a time, indexed by column name.
Returns Generator<int, array<string, string|null>>
tables()
php
public function tables(): arrayReturns list<string>
types()
php
public function types(string $table): arrayThe Table Schema type of each column of a table (integer, number, date or string).
Returns array<string, string>