Container
[ class tree: Container ] [ index: Container ] [ all elements ]

Source for file Word.php

Documentation is available at Word.php

  1. <?php
  2. /**
  3.  * Mai_Container_Word
  4.  * 
  5.  * Copyright (C) 2009  Mai (Me Artificial Intelligence)
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  * 
  20.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  21.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  22.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  23.  * @link http://www.launchpad.net/mai
  24.  * 
  25.  * @category Mai
  26.  * @package Container
  27.  * @subpackage Word
  28.  * 
  29.  */
  30.  
  31. /** Load required file */
  32. {
  33.     require_once 'Mai/Container/Word/Interface.php';
  34. }
  35.  
  36. /**
  37.  * Mai_Container_Word is a container for a single word.
  38.  * 
  39.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  40.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  41.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  42.  * @link http://www.launchpad.net/mai
  43.  * 
  44.  * @category Mai
  45.  * @package Container
  46.  * @subpackage Sentence
  47.  *
  48.  */
  49. class Mai_Container_Word implements Mai_Container_Word_Interface
  50. {
  51.     /**
  52.      * @var String The word.
  53.      */
  54.     private $_word;
  55.     /**
  56.      * @var Int Type of the word. (@see Mai)
  57.      */
  58.     private $_type = 0;
  59.     
  60.     /**
  61.      * @var Int Time of the word. (@see Mai)
  62.      */
  63.     private $_time = 0;
  64.     
  65.     /**
  66.      * @var Int Number ('meervoud'/'enkelvoud') (@see Mai)
  67.      */
  68.     private $_number0;
  69.     
  70.     /**
  71.      * @var Int Person (@see Mai)
  72.      */
  73.     private $_person = 0;
  74.     
  75.     /*
  76.      * @var Int Ww (verb) id
  77.      */
  78.     private $_wwId = 0;
  79.     
  80.     /*
  81.      * @param $word Word to store.
  82.      * @return void
  83.      */
  84.     public function __construct($word)
  85.     {
  86.         if(!is_string($word))
  87.         {
  88.             trigger_error('Word must be a string'E_USER_ERROR);
  89.         }
  90.         
  91.         $this->_word = $word;
  92.     }
  93.     /**
  94.      * Return the word.
  95.      * @return String 
  96.      */
  97.     public function getWord()
  98.     {
  99.         return $this->_word;
  100.     }
  101.     
  102.     /**
  103.      * Return the type of the word.
  104.      * @return Int 
  105.      */
  106.     public function getType()
  107.     {
  108.         return $this->_type;
  109.     }
  110.     
  111.     /**
  112.      * Return the time.
  113.      * @return Int 
  114.      */
  115.     public function getTime()
  116.     {
  117.         return $this->_time;
  118.     }
  119.     
  120.     /**
  121.      * Return the number.
  122.      * @return Int 
  123.      */
  124.     public function getNumber()
  125.     {
  126.         return $this->_number;
  127.     }
  128.     
  129.     /**
  130.      * Return the person.
  131.      * @return Int 
  132.      */
  133.     public function getPerson()
  134.     {
  135.         return $this->_person;
  136.     }
  137.     
  138.     /**
  139.      * Set type.
  140.      * @return void 
  141.      */
  142.     public function setType($type)
  143.     {
  144.         if(!in_array($typeMai::$allowedWordTypes&& $time !== 0)
  145.         {
  146.             trigger_error("Type is not valid."E_USER_NOTICE);
  147.         }
  148.         
  149.         $this->_type = $type;
  150.     }
  151.     
  152.     /**
  153.      * Set time.
  154.      * @return void 
  155.      */
  156.     public function setTime($time)
  157.     {
  158.         if(!in_array($timeMai::$allowedTimes&& $time !== 0)
  159.         {
  160.             trigger_error("Time is not valid."E_USER_NOTICE);
  161.         }
  162.         
  163.         $this->_time = $time;
  164.     }
  165.     
  166.     /**
  167.      * Set number.
  168.      * @return void 
  169.      */
  170.     public function setNumber($number)
  171.     {
  172.         if(!in_array($numberMai::$allowedNumbers&& $number !== 0)
  173.         {
  174.             trigger_error("Number is not valid."E_USER_NOTICE);
  175.         }
  176.         
  177.         $this->_number = $number;
  178.     }
  179.     
  180.     /**
  181.      * Set person.
  182.      * @return void 
  183.      */
  184.     public function setPerson($person)
  185.     {
  186.         if(!in_array($personMai::$allowedPersons&& $person !== 0)
  187.         {
  188.             trigger_error("Person is not valid."E_USER_NOTICE);
  189.         }
  190.         
  191.         $this->_person = $person;
  192.     }
  193.     
  194.     /**
  195.      * Set ww (verb) id
  196.      * @param $wwId 
  197.      */
  198.     public function setWwId($id)
  199.     {
  200.         $this->_wwId = $id;    
  201.     }
  202.     
  203.     /**
  204.      * Get ww (verb) id.
  205.      * @return int. 
  206.      */
  207.     public function getWwId()
  208.     {
  209.         return $this->_wwId;
  210.     }
  211. }

Documentation generated on Mon, 27 Jul 2009 19:55:14 +0200 by phpDocumentor 1.4.1