florianeckerstorfer/data-import-extra

Extra utlities for ddeboer/data-import.

dev-master 2014-09-24 18:32 UTC

This package is auto-updated.

Last update: 2024-11-20 10:09:34 UTC


README

Additional item and value converters for ddeboer/data-import.

Build Status Code Climate Test Coverage

Installation

You can install DataImportExtra using Composer:

$ composer require florianeckerstorfer/data-import-extra:@stable

Usage

Item Converters

RemoveEmptyColumnItemConverter

Removes columns with an empty key from the items.

$converter = new RemoveEmptyColumnItemConverter();
$input = ['key' => 'value', '' => '', "\n" => '', ' ' => ''];
$this->converter->convert($input); // ['key' => 'value']

Value Converters

MultiplicationValueConverter

Multiplies the given input value with the multiplicator.

$converter = new MultiplicationValueConverter(10);
$converter->convert(3); // 30

StringReplaceValueConverter

Replaces the search string with the replace string in the input string.

$converter = new StringReplaceValueConverter('foo', 'baz')
$converter->convert('foobar'); // bazbar

ChainValueConverter

Executes multiple value converters. Great for composing chains of value converters and reusing them for multiple fields or in multiple workflows.

// Convert a money value (in german format with , instead of .) into cents.
$converter = new ChainValueConverter();
$converter->addValueConverter(new StringReplaceValueConverter(',', '.'))
          ->addValueConverter(new MultiplicationValueConverter(100));
$converter->convert('42,69'); // 4269

Author

Florian Eckerstorfer

License