Apache Zeta Components Manual :: File Source for cell.php

Source for file cell.php

Documentation is available at cell.php

  1. <?php
  2. /**
  3.  * File containing the ezcConsoleTableCell class.
  4.  *
  5.  * Licensed to the Apache Software Foundation (ASF) under one
  6.  * or more contributor license agreements.  See the NOTICE file
  7.  * distributed with this work for additional information
  8.  * regarding copyright ownership.  The ASF licenses this file
  9.  * to you under the Apache License, Version 2.0 (the
  10.  * "License"); you may not use this file except in compliance
  11.  * with the License.  You may obtain a copy of the License at
  12.  * 
  13.  *   http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing,
  16.  * software distributed under the License is distributed on an
  17.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18.  * KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations
  20.  * under the License.
  21.  *
  22.  * @package ConsoleTools
  23.  * @version //autogentag//
  24.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25.  * @filesource
  26.  */
  27.  
  28. /**
  29.  * Representation of a table cell.
  30.  * An object of this class represents a table cell. A cell has a certain content,
  31.  * may apply a format to this data, align the data in the cell and so on.
  32.  *
  33.  * This class stores the cells for the {@link ezcConsoleTable} class.
  34.  *
  35.  * @see ezcConsoleTableRow
  36.  * 
  37.  * @property string $content 
  38.  *            Text displayed in the cell.
  39.  * @property string $format 
  40.  *            Format applied to the displayed text.
  41.  * @property int $align 
  42.  *            Alignment of the text inside the cell.  Must be one of
  43.  *            ezcConsoleTable::ALIGN_ constants. See
  44.  *            {@link ezcConsoleTable::ALIGN_LEFT},
  45.  *            {@link ezcConsoleTable::ALIGN_RIGHT} and
  46.  *            {@link ezcConsoleTable::ALIGN_CENTER}.
  47.  *
  48.  * @package ConsoleTools
  49.  * @version //autogen//
  50.  */
  51. {
  52.     /**
  53.      * Container to hold the properties
  54.      *
  55.      * @var array(string=>mixed) 
  56.      */
  57.     protected $properties;
  58.  
  59.     /**
  60.      * Create a new ezcConsoleProgressbarCell.
  61.      * Creates a new ezcConsoleProgressbarCell. You can either submit the cell
  62.      * data through the constructor or set them as properties.
  63.      * 
  64.      * @param string $content Content of the cell.
  65.      * @param string $format  Format to display the cell with.
  66.      * @param mixed $align    Alignment of the content in the cell.
  67.      * @return void 
  68.      */
  69.     public function __construct$content ''$format 'default'$align ezcConsoleTable::ALIGN_DEFAULT )
  70.     {
  71.         $this->__set'content'$content );
  72.         $this->__set'format'$format );
  73.         $this->__set'align'$align );
  74.     }
  75.  
  76.     /**
  77.      * Property read access.
  78.      * 
  79.      * @param string $key Name of the property.
  80.      * @return mixed Value of the property or null.
  81.      *
  82.      * @throws ezcBasePropertyNotFoundException
  83.      *          If the the desired property is not found.
  84.      * @ignore
  85.      */
  86.     public function __get$key )
  87.     {
  88.         if isset$this->properties[$key) )
  89.         {
  90.             return $this->properties[$key];
  91.         }
  92.         throw new ezcBasePropertyNotFoundException$key );
  93.     }
  94.  
  95.     /**
  96.      * Property write access.
  97.      * 
  98.      * @param string $key Name of the property.
  99.      * @param mixed $val  The value for the property.
  100.      *
  101.      * @throws ezcBaseValueException
  102.      *          If a the value submitted for the align is not in the range of
  103.      *          {@link ezcConsoleTable::ALIGN_LEFT},
  104.      *          {@link ezcConsoleTable::ALIGN_CENTER},
  105.      *          {@link ezcConsoleTable::ALIGN_RIGHT},
  106.      *          {@link ezcConsoleTable::ALIGN_DEFAULT}
  107.      *
  108.      * @ignore
  109.      */
  110.     public function __set$key$val )
  111.     {
  112.             
  113.         switch $key )
  114.         {
  115.             case 'content':
  116.                 if is_string$val === false )
  117.                 {
  118.                     throw new ezcBaseValueException$key$val"string" );
  119.                 }
  120.                 break;
  121.             case 'format':
  122.                 if is_string$val === false || strlen$val )
  123.                 {
  124.                     throw new ezcBaseValueException$key$val"string, length > 0" );
  125.                 }
  126.                 break;
  127.             case 'align':
  128.                 if $val !== ezcConsoleTable::ALIGN_LEFT 
  129.                   && $val !== ezcConsoleTable::ALIGN_CENTER 
  130.                   && $val !== ezcConsoleTable::ALIGN_RIGHT 
  131.                   && $val !== ezcConsoleTable::ALIGN_DEFAULT 
  132.                 )
  133.                 {
  134.                     throw new ezcBaseValueException$key,  $val'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
  135.                 }
  136.                 break;
  137.             default:
  138.                 throw new ezcBasePropertyNotFoundException$key );
  139.         }
  140.         $this->properties[$key$val;
  141.         return;
  142.     }
  143.  
  144.     /**
  145.      * Property isset access.
  146.      * 
  147.      * @param string $key Name of the property.
  148.      * @return bool True is the property is set, otherwise false.
  149.      * @ignore
  150.      */
  151.     public function __isset$key )
  152.     {
  153.         switch $key )
  154.         {
  155.             case 'content':
  156.             case 'format':
  157.             case 'align':
  158.                 return true;
  159.             default:
  160.                 break;
  161.         }
  162.         return false;
  163.     }
  164.  
  165. }
  166.  
  167. ?>
Documentation generated by phpDocumentor 1.4.3