designbeat/csv-matcher

This package is abandoned and no longer maintained. The author suggests using the contributte/utils package instead.

1.0 2015-10-05 17:44 UTC

This package is not auto-updated.

Last update: 2019-10-28 12:48:08 UTC


README

Downloads this Month Latest stable

Install

$ composer require designbeat/csv-matcher

Usage

See more in tests.

use DesignBeat\Matchers\CSV\CsvMatcher;
use DesignBeat\Matchers\CSV\CsvReader;

$scheme = [
    0 => 'user.name',
    1 => 'user.surname',
    2 => 'city',
    3 => 'extra.id',
    4 => 'extra.x',
];

$matcher = new CsvMatcher(new CsvReader(__DIR__ . '/tests/cases/files/fixtures.csv'));
$result = $matcher->match($scheme);

Result is:

0 => [
    'user' => [
        'name' => 'Milan',
        'surname' => 'Sulc',
    ],
    'city' => 'HK',
    'extra' => [
        'id' => '123456',
        'x' => 'foo',
    ],
],
1 => [
    'user' => [
        'name' => 'John',
        'surname' => 'Doe',
    ],
    'city' => 'Doens',
    'extra' => [
        'id' => '111111',
        'x' => 'bar',
    ],
],