DivineOmega / uxdm

🔀 UXDM helps developers migrate data from one system or format to another.
GNU Lesser General Public License v3.0
167 stars 9 forks source link

Make source/migrator object properties protected #22

Closed dextermb closed 5 years ago

dextermb commented 5 years ago

Instead of making the properties private I feel that it would be easier to extend and manipulate the properties if they were protected.

From:
<?php
namespace App\Utilities;

use DivineOmega\uxdm\Objects\Sources\CSVSource as Base;

class GasCsvSource extends Base
{
    /** @var $file */
    protected $file;

    /** @var array|string[] $fields */
    protected $fields = [];

    /** @var int $perPage */
    protected $perPage = 20000;

    /**
     * @param $file
     */
    public function __construct($file)
    {
        parent::__construct($file);

        $this->file = $file;
        $this->fields = [
            // Custom fields
        ];
    }
}
To:
<?php
namespace App\Utilities;

use DivineOmega\uxdm\Objects\Sources\CSVSource as Base;

class GasCsvSource extends Base
{
    /** @var int $perPage */
    protected $perPage = 20000;

    /**
     * @param $file
     */
    public function __construct($file)
    {
        parent::__construct($file);

        $this->file = $file;
        $this->fields = [
            // Custom fields
        ];
    }
}

As a minimal example, you wouldn't have to re-declare the properties with a new scope. This is also useful for when changing the logic of getDataRows or getCSVLines in the case of a CSV as file is private and cannot be accessed in an extended class.