leomarquine / php-etl

Extract, Transform and Load data using PHP.
MIT License
178 stars 81 forks source link

Simple Transformer for adding columns #57

Closed jlopez0313 closed 3 years ago

jlopez0313 commented 3 years ago
<?php

/**
 * @author      Wizacha DevTeam <dev@wizacha.com>
 * @copyright   Copyright (c) Wizacha
 * @copyright   Copyright (c) Leonardo Marquine
 * @license     MIT
 */

declare(strict_types=1);

namespace Wizaplace\Etl\Transformers;

use Wizaplace\Etl\Row;

class AddColumns extends Transformer
{
    /**
     * Transformer columns.
     *
     * @var string[]
     */
    protected $columns = [];

    /**
     * Properties that can be set via the options method.
     *
     * @var string[]
     */
    protected $availableOptions = ['columns'];

    /**
     * Initialize the step.
     */
    public function initialize(): void
    {
    }

    /**
     * Transform the given row.
     */
    public function transform(Row $row): void
    {
        foreach( $this->columns as $key => $val ) {
            $row[ $key ] = $val;
        }
    }

}
ecourtial commented 3 years ago

Hi @jlopez0313 the destination of your PR is not good. You must do it toward the master branch of https://github.com/wizaplace/php-etl :)