<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2016/12/28
 * Time: 下午2:25
 */
class time_interval
{
    private $reset_time;
    private $interval;

    public function __construct($interval = 60) {
        $this->reset_time = 0;
        $this->interval = $interval;
    }

    public function need_init()
    {
        if($this->reset_time == 0) {
            $this->reset_time = time();
            return true;
        }
        else if((time() - $this->reset_time) < $this->interval) {
            return false;
        }
        else
        {
            $this->reset_time = time();
            return true;
        }
    }
}