Skip to content
Snippets Groups Projects
DisciplineBuilder.php 1.8 KiB
Newer Older
xamgore's avatar
xamgore committed
<?php defined('SYSPATH') or die('No direct script access.');

class Model_Helper_DisciplineBuilder extends Model
{
    private $data;

    public function create() {
        if (count($this->data) != 8)
            throw new ErrorException;
        return new Model_Discipline($this->data, false);
    }

    function & author($id) {
        if (!is_numeric($id) && $id <= 0)
            throw new InvalidArgumentException();
        $this->data['authorID'] = $id;
        return $this;
    }

    function & grade($id) {
        if (!is_numeric($id) && $id <= 0)
            throw new InvalidArgumentException();
        $this->data['gradeID'] = $id;
        return $this;
    }

    function & faculty($id) {
        if (!is_numeric($id) && $id <= 0)
            throw new InvalidArgumentException();
        $this->data['facultyID'] = $id;
        return $this;
    }

    function & subject($id) {
        if (!is_numeric($id) && $id <= 0)
            throw new InvalidArgumentException();
        $this->data['subjectID'] = $id;
        return $this;
    }

    function & lectures($hours) {
        if (!is_numeric($hours) && $hours < 0)
            throw new InvalidArgumentException();
        $this->data['lectures'] = $hours;
        return $this;
    }

    function & practice($hours) {
        if (!is_numeric($hours) && $hours < 0)
            throw new InvalidArgumentException();
        $this->data['practice'] = $hours;
        return $this;
    }

    function & labs($hours) {
        if (!is_numeric($hours) && $hours < 0)
            throw new InvalidArgumentException();
        $this->data['labs'] = $hours;
        return $this;
    }

    function & type($name) {
        if (!$name)  // todo: enum
            throw new InvalidArgumentException();
        $this->data['type'] = $name;
        return $this;
    }
}