View file upload/src/addons/AddonsLab/Core/StepRunner/RunState.php

File size: 1.93Kb
<?php
/** 
This software is furnished under a license and may be used and copied
only  in  accordance  with  the  terms  of such  license and with the
inclusion of the above copyright notice.  This software  or any other
copies thereof may not be provided or otherwise made available to any
other person.  No title to and  ownership of the  software is  hereby
transferred.                                                         
                                                                     
You may not reverse  engineer, decompile, defeat  license  encryption
mechanisms, or  disassemble this software product or software product
license.  AddonsLab may terminate this license if you don't comply with
any of these terms and conditions.  In such event,  licensee  agrees 
to return licensor  or destroy  all copies of software  upon termination 
of the license.
*/


namespace AddonsLab\Core\StepRunner;
class RunState
{
    public function __construct($data = array())
    {
        foreach ($data AS $key => $value) {
            if (!property_exists($this, $key)) {
                throw new \RuntimeException('The data provider to run status can not contain key ' . $key);
            }

            $this->$key = $value;
        }
    }

    public function getAsArray()
    {
        return array(
            'step_id' => $this->step_id,
            'index' => $this->index,
            'total' => $this->total,
            'per_page' => $this->per_page,
            'step_data' => $this->step_data,
        );
    }

    public $step_id = false;
    public $index = 0; // the numeric index or ID of last imported item
    public $total = false; // total number of items to import
    public $per_page = 1000; // the number of items to import per page
    public $step_data = array(); // any additional data can be stored here by the steps
    public $messages = array(); // importer steps can put the messages they want here to persist during the entire import
}