<?php
/**
*+-----------------------------------------------------------------------+
*| CliParser v0.1 - 19 Jul 2006 |
*+-----------------------------------------------------------------------+
*| Diego do Nascimento Feitosa |
*| hide@address.com |
*| www.dnfeitosa.com |
*| São Paulo/SP - Brasil |
*| The latest version can be found at www.dnfeitosa.com |
*+-----------------------------------------------------------------------+
*| CliParser is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published by |
*| the Free Software Foundation; either version 2 of the License, or |
*| (at your option) any later version. |
*| |
*| CliParser is distributed in the hope that it will be useful, but |
*| WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
*| General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with CliParser; if not, write to the Free Software |
*| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
*| 02111-1307 USA |
*+-----------------------------------------------------------------------+
**/
abstract class CliToken {
protected $token = null;
protected $value = null;
protected $description = null;
protected $assigned = false;
public function __construct($token) {
$this->token = $token;
}
public function getToken() {
return $this->token;
}
protected function setTokenValue($value) {
$this->value = $value;
}
public function setValue($value) {
if ($this->assignCondition($value)) {
$this->setTokenValue($value);
}
}
public function setDescription($message) {
$this->description = $message;
}
public function getDescription() {
return $this->description;
}
public function getHelpMessage() {
return sprintf("\t%s\t%s\n", $this->token, $this->description);
}
public function getValue() {
return $this->value;
}
abstract public function assignCondition($value);
function isAssigned() {
if (!is_null($this->value)) {
$this->assigned = true;
} else {
$this->assigned = false;
}
return $this->assigned;
}
}
?>