Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
digitalascetic/batch-util / CountProgressMonitor.php
Size: Mime:
<?php
/**
 * Created by IntelliJ IDEA.
 * User: martino
 * Date: 07/04/18
 * Time: 10:17
 */

namespace DigitalAscetic\BatchUtil;

/**
 * Class CountProgressMonitor
 * @package DigitalAscetic\BatchUtil
 */
class CountProgressMonitor extends AbstractProgressMonitor
{

    /**
     * @var int
     */
    private int $count;

    /**
     * @var int
     */
    private int $totalSteps;

    /**
     * @var array
     */
    private array $messages;

    /**
     * CountProgressMonitor constructor.
     */
    public function __construct()
    {
        parent::__construct();
        $this->count = 0;
        $this->messages = array();
    }


    /**
     * @param null $data
     */
    public function start($data = null): void
    {
        $this->started = true;
    }

    /**
     * @param null $data
     */
    public function advance($data = null): void
    {
        $this->count++;
    }

    /**
     * @param null $data
     */
    public function finish($data = null): void
    {
        $this->finished = true;
    }

    /**
     * @param null $data
     */
    public function message($data = null): void
    {
        $this->messages[] = $data;
    }

    /**
     * @param int $count
     */
    public function setTotalSteps(int $count = 0): void
    {
        $this->totalSteps = $count;
    }

    /**
     * @return int
     */
    public function getCount(): int
    {
        return $this->count;
    }

    /**
     * @return int
     */
    public function getTotalSteps(): int
    {
        return $this->totalSteps;
    }

    /**
     * @return float
     */
    public function getProgressPercent(): float
    {
        return $this->count / $this->totalSteps;
    }

}