models/classes/runner/time/QtiTimer.php
public function load()
    {
        if (!$this->storage) {
            throw new InvalidStorageException('A storage must be defined in order to store the data!');
        }
        
        $data = $this->storage->load();

        if (isset($data)) {
            if (!is_array($data)) {
                $data = [
                    self::STORAGE_KEY_TIME_LINE => $data,
                ];
            }

            if (isset($data[self::STORAGE_KEY_TIME_LINE])) {
                $this->timeLine = $this->unserializeTimeLine($data[self::STORAGE_KEY_TIME_LINE]);
            } else {
                $this->timeLine = new QtiTimeLine();
            }

            if (isset($data[self::STORAGE_KEY_EXTRA_TIME])) {
                $this->extraTime = $data[self::STORAGE_KEY_EXTRA_TIME];
            } else {
                $this->extraTime = 0;
            }

            if (isset($data[self::STORAGE_KEY_EXTENDED_TIME])) {
                $this->extendedTime = $data[self::STORAGE_KEY_EXTENDED_TIME];
            } else {
                $this->extendedTime = 0;
            }
            if (isset($data[self::STORAGE_KEY_CONSUMED_EXTRA_TIME])) {
                $this->consumedExtraTime = $data[self::STORAGE_KEY_CONSUMED_EXTRA_TIME];
            } else {
                $this->consumedExtraTime = 0;
            }

            if (!$this->timeLine instanceof TimeLine) {
                throw new InvalidDataException('The storage did not provide acceptable data when loading!');
            }
        }

        return $this;
    }
public function load()
    {
        if (!$this->storage) {
            throw new InvalidStorageException('A storage must be defined in order to store the data!');
        }
        
        $data = $this->storage->load();

        if (isset($data)) {
            if (!is_array($data)) {
                $data = [
                    self::STORAGE_KEY_TIME_LINE => $data,
                ];
            }

            if (isset($data[self::STORAGE_KEY_TIME_LINE])) {
                $this->timeLine = $this->unserializeTimeLine($data[self::STORAGE_KEY_TIME_LINE]);
            } else {
                $this->timeLine = new QtiTimeLine();
            }

            if (isset($data[self::STORAGE_KEY_EXTRA_TIME])) {
                $this->extraTime = $data[self::STORAGE_KEY_EXTRA_TIME];
            } else {
                $this->extraTime = 0;
            }

            if (isset($data[self::STORAGE_KEY_EXTENDED_TIME])) {
                $this->extendedTime = $data[self::STORAGE_KEY_EXTENDED_TIME];
            } else {
                $this->extendedTime = 0;
            }
            if (isset($data[self::STORAGE_KEY_CONSUMED_EXTRA_TIME])) {
                $this->consumedExtraTime = $data[self::STORAGE_KEY_CONSUMED_EXTRA_TIME];
            } else {
                $this->consumedExtraTime = 0;
            }

            if (!$this->timeLine instanceof TimeLine) {
                throw new InvalidDataException('The storage did not provide acceptable data when loading!');
            }
        }

        return $this;
    }
public function load ( ) { if ( ! $ this -> storage ) { throw new InvalidStorageException ( 'A storage must be defined in order to store the data!' ) ; } $ data = $ this -> storage -> load ( ) ; if ( isset ( $ data ) ) { if ( ! is_array ( $ data ) ) { $ data = [ self :: STORAGE_KEY_TIME_LINE => $ data , ] ; } if ( isset ( $ data [ self :: STORAGE_KEY_TIME_LINE ] ) ) { $ this -> timeLine = $ this -> unserializeTimeLine ( $ data [ self :: STORAGE_KEY_TIME_LINE ] ) ; } else { $ this -> timeLine = new QtiTimeLine ( ) ; } if ( isset ( $ data [ self :: STORAGE_KEY_EXTRA_TIME ] ) ) { $ this -> extraTime = $ data [ self :: STORAGE_KEY_EXTRA_TIME ] ; } else { $ this -> extraTime = 0 ; } if ( isset ( $ data [ self :: STORAGE_KEY_EXTENDED_TIME ] ) ) { $ this -> extendedTime = $ data [ self :: STORAGE_KEY_EXTENDED_TIME ] ; } else { $ this -> extendedTime = 0 ; } if ( isset ( $ data [ self :: STORAGE_KEY_CONSUMED_EXTRA_TIME ] ) ) { $ this -> consumedExtraTime = $ data [ self :: STORAGE_KEY_CONSUMED_EXTRA_TIME ] ; } else { $ this -> consumedExtraTime = 0 ; } if ( ! $ this -> timeLine instanceof TimeLine ) { throw new InvalidDataException ( 'The storage did not provide acceptable data when loading!' ) ; } } return $ this ; }
Loads the data from the storage
@return Timer
@throws InvalidStorageException
@throws InvalidDataException
Loads the data from the storage