public function add_category(category $cat) {
        $name = $cat->name;
        if (isset($this->categories[$name])) {
            throw new \coding_exception("Category name $name already used");
        }
        $this->categories[$cat->name] = $cat;
    }
public function add_category(category $cat) {
        $name = $cat->name;
        if (isset($this->categories[$name])) {
            throw new \coding_exception("Category name $name already used");
        }
        $this->categories[$cat->name] = $cat;
    }
public function add_category ( category $ cat ) { $ name = $ cat -> name ; if ( isset ( $ this -> categories [ $ name ] ) ) { throw new \ coding_exception ( "Category name $name already used" ) ; } $ this -> categories [ $ cat -> name ] = $ cat ; }
Add a category to the tree.

@param category $cat category object.

@throws \coding_exception
Add a category to the tree .