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

Source for file table.php

Documentation is available at table.php

  1. <?php
  2. /**
  3.  * File containing the ezcConsoleTableOptions 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.  * Struct class to store the options of the ezcConsoleTable class.
  30.  * This class stores the options for the {@link ezcConsoleTable} class.
  31.  *
  32.  * @property mixed $colWidth 
  33.  *            Either 'auto' for automatic selection of column widths, or an
  34.  *            array of column widths like array( 10, 30, 10 ).
  35.  * @property int $colWrap 
  36.  *            Wrap style of text contained in strings. See {@link }
  37.  *            ezcConsoleTable::WRAP_AUTO}, {@link ezcConsoleTable::WRAP_NONE}
  38.  *            and {@link ezcConsoleTable::WRAP_CUT}.
  39.  * @property int $defaultAlign 
  40.  *            Standard column alignment, applied to cells that have to explicit
  41.  *            alignment assigned. See {@link ezcConsoleTable::ALIGN_LEFT},
  42.  *            {@link ezcConsoleTable::ALIGN_RIGHT}{@link }
  43.  *            ezcConsoleTable::ALIGN_CENTER} and {@link }
  44.  *            ezcConsoleTable::ALIGN_DEFAULT}.
  45.  * @property string $colPadding 
  46.  *            Padding characters for side padding between data and lines.
  47.  * @property int $widthType 
  48.  *            Type of the given table width (fixed or maximal value).
  49.  * @property string $lineVertical 
  50.  *            Character to use for drawing vertical lines. Null to switch off.
  51.  * @property string $lineHorizontal 
  52.  *            Character to use for drawing horizontal lines. Null to switch off.
  53.  * @property string $corner 
  54.  *            Character to use for drawing line corners. Null to switch off.
  55.  * @property string $defaultFormat 
  56.  *            Standard column content format, applied to cells that have
  57.  *            "default" as the content format.
  58.  * @property string $defaultBorderFormat 
  59.  *            Standard border format, applied to rows that have 'default' as the
  60.  *            border format.
  61.  * 
  62.  * @package ConsoleTools
  63.  * @version //autogen//
  64.  */
  65. {
  66.     protected $properties = array(
  67.         'colWidth'            => 'auto',
  68.         'colWrap'             => ezcConsoleTable::WRAP_AUTO,
  69.         'defaultAlign'        => ezcConsoleTable::ALIGN_LEFT,
  70.         'colPadding'          => ' ',
  71.         'widthType'           => ezcConsoleTable::WIDTH_MAX,
  72.         'lineVertical'        => '-',
  73.         'lineHorizontal'      => '|',
  74.         'corner'              => '+',
  75.         'defaultFormat'       => 'default',
  76.         'defaultBorderFormat' => 'default',
  77.     );
  78.  
  79.     /**
  80.      * Construct a new options object.
  81.      *
  82.      * NOTE: For backwards compatibility reasons the old method of instantiating this class is kept,
  83.      * but the usage of the new version (providing an option array) is highly encouraged.
  84.      * 
  85.      * @param array(string=>mixed) $options The initial options to set.
  86.      * @return void 
  87.      *
  88.      * @throws ezcBasePropertyNotFoundException
  89.      *          If the value for the property options is not an instance of
  90.      * @throws ezcBaseValueException
  91.      *          If the value for a property is out of range.
  92.      */
  93.     public function __construct()
  94.     {
  95.         $args func_get_args();
  96.         if func_num_args(=== && is_array$args[0&& !is_intkey$args[0) ) )
  97.         {
  98.             parent::__construct$args[0);
  99.         }
  100.         else
  101.         {
  102.             foreach $args as $id => $val )
  103.             {
  104.                 switch $id )
  105.                 {
  106.                     case 0:
  107.                         $this->__set'colWidth'$val );
  108.                         break;
  109.                     case 1:
  110.                         $this->__set'colWrap'$val );
  111.                         break;
  112.                     case 2:
  113.                         $this->__set'defaultAlign'$val );
  114.                         break;
  115.                     case 3:
  116.                         $this->__set'colPadding'$val );
  117.                         break;
  118.                     case 4:
  119.                         $this->__set'widthType'$val );
  120.                         break;
  121.                     case 5:
  122.                         $this->__set'lineVertical'$val );
  123.                         break;
  124.                     case 6:
  125.                         $this->__set'lineHorizontal'$val );
  126.                         break;
  127.                     case 7:
  128.                         $this->__set'corner'$val );
  129.                         break;
  130.                     case 8:
  131.                         $this->__set'defaultFormat'$val );
  132.                         break;
  133.                     case 9:
  134.                         $this->__set'defaultBorderFormat'$val );
  135.                         break;
  136.                 }
  137.             }
  138.         }
  139.     }
  140.  
  141.     /**
  142.      * Property write access.
  143.      * 
  144.      * @throws ezcBasePropertyNotFoundException
  145.      *          If a desired property could not be found.
  146.      * @throws ezcBaseValueException
  147.      *          If a desired property value is out of range.
  148.      *
  149.      * @param string $propertyName Name of the property.
  150.      * @param mixed $val  The value for the property.
  151.      * @ignore
  152.      */
  153.     public function __set$propertyName$val )
  154.     {
  155.         switch $propertyName )
  156.         {
  157.             case 'colWidth':
  158.                 if is_array$val === false && is_string$val && $val !== 'auto' ) )
  159.                 {
  160.                     throw new ezcBaseValueException$propertyName$val'array(int) or "auto"' );
  161.                 }
  162.                 break;
  163.             case 'colWrap':
  164.                 if $val !== ezcConsoleTable::WRAP_AUTO && $val !== ezcConsoleTable::WRAP_NONE && $val !== ezcConsoleTable::WRAP_CUT )
  165.                 {
  166.                     throw new ezcBaseValueException$propertyName$val'ezcConsoleTable::WRAP_AUTO, ezcConsoleTable::WRAP_NONE, ezcConsoleTable::WRAP_CUT' );
  167.                 }
  168.                 break;
  169.             case 'defaultAlign':
  170.                 if $val !== ezcConsoleTable::ALIGN_DEFAULT && $val !== ezcConsoleTable::ALIGN_LEFT && $val !== ezcConsoleTable::ALIGN_CENTER && $val !== ezcConsoleTable::ALIGN_RIGHT )
  171.                 {
  172.                     throw new ezcBaseValueException$propertyName$val'ezcConsoleTable::ALIGN_DEFAULT, ezcConsoleTable::ALIGN_LEFT, ezcConsoleTable::ALIGN_CENTER, ezcConsoleTable::ALIGN_RIGHT' );
  173.                 }
  174.                 break;
  175.             case 'colPadding':
  176.                 if !is_string$val ) )
  177.                 {
  178.                     throw new ezcBaseValueException$propertyName$val'string' );
  179.                 }
  180.                 break;
  181.             case 'widthType':
  182.                 if $val !== ezcConsoleTable::WIDTH_MAX && $val !== ezcConsoleTable::WIDTH_FIXED )
  183.                 {
  184.                     throw new ezcBaseValueException$propertyName$val'ezcConsoleTable::WIDTH_MAX, ezcConsoleTable::WIDTH_FIXED' );
  185.                 }
  186.                 break;
  187.             case 'lineVertical':
  188.             case 'lineHorizontal':
  189.             case 'corner':
  190.                 if ( ( is_string$val === false || strlen$val !== && $val !== null )
  191.                 {
  192.                     throw new ezcBaseValueException$propertyName$val'string, length = 1, or null' );
  193.                 }
  194.                 break;
  195.             case 'defaultFormat':
  196.                 if is_string$val === false || strlen$val )
  197.                 {
  198.                     throw new ezcBaseValueException$propertyName$val'string, length = 1' );
  199.                 }
  200.                 break;
  201.             case 'defaultBorderFormat':
  202.                 if is_string$val === false || strlen$val )
  203.                 {
  204.                     throw new ezcBaseValueException$propertyName$val'string, length = 1' );
  205.                 }
  206.                 break;
  207.             default:
  208.                 throw new ezcBasePropertyNotFoundException$propertyName );
  209.         }
  210.         $this->properties[$propertyName$val;
  211.     }
  212. }
  213.  
  214. ?>
Documentation generated by phpDocumentor 1.4.3