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

Source for file progressbar.php

Documentation is available at progressbar.php

  1. <?php
  2. /**
  3.  * File containing the ezcConsoleProgressbarOptions 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 ezcConsoleOutput class.
  30.  * This class stores the options for the {@link ezcConsoleOutput} class.
  31.  *
  32.  * @property string $barChar 
  33.  *            The character to fill the bar with, during progress indication.
  34.  * @property string $emptyChar 
  35.  *            The character to pre-fill the bar, before indicating progress.
  36.  * @property string $formatString 
  37.  *            The format string to describe the complete progressbar.
  38.  * @property string $fractionFormat 
  39.  *            Format to display the fraction value.
  40.  * @property string $processChar 
  41.  *            The character for the end of the progress area (the arrow!).
  42.  * @property int $redrawFrequency 
  43.  *            How often to redraw the progressbar (on every Xth call to advance()).
  44.  * @property int $step 
  45.  *            How many steps to advance the progressbar on each call to advance().
  46.  * @property int $width 
  47.  *            The width of the bar itself.
  48.  * @property string $actFormat 
  49.  *            The format to display the actual value with.
  50.  * @property string $maxFormat 
  51.  *            The format to display the actual value with.
  52.  * @property int $minVerbosity 
  53.  *            Defines the minimum {ezcConsoleOutputOptions->$verbosityLevel}
  54.  *            that is needed by the progress bar to be rendered. If
  55.  *            $verbosityLevel is lower, the bar is skipped. Default is 0 to
  56.  *            render always.
  57.  * @property int $maxVerbosity 
  58.  *            Defines the maximum {ezcConsoleOutputOptions->$verbosityLevel} on
  59.  *            which the progress bar is rendered. If $verbosityLevel is higher,
  60.  *            the bar is skipped. Default is false, to render always.
  61.  * 
  62.  * @package ConsoleTools
  63.  * @version //autogen//
  64.  */
  65. {
  66.  
  67.     protected $properties = array(
  68.         'barChar'         => "+",
  69.         'emptyChar'       => "-",
  70.         'formatString'    => "%act% / %max% [%bar%] %fraction%%",
  71.         'fractionFormat'  => "%01.2f",
  72.         'progressChar'    => ">",
  73.         'redrawFrequency' => 1,
  74.         'step'            => 1,
  75.         'width'           => 78,
  76.         'actFormat'       => '%.0f',
  77.         'maxFormat'       => '%.0f',
  78.         'minVerbosity'    => 1,
  79.         'maxVerbosity'    => false,
  80.     );
  81.  
  82.     /**
  83.      * Option write access.
  84.      * 
  85.      * @throws ezcBasePropertyNotFoundException
  86.      *          If a desired property could not be found.
  87.      * @throws ezcBaseValueException
  88.      *          If a desired property value is out of range.
  89.      *
  90.      * @param string $key Name of the property.
  91.      * @param mixed $value  The value for the property.
  92.      * @ignore
  93.      */
  94.     public function __set$key$value )
  95.     {
  96.         switch $key )
  97.         {
  98.             case "barChar":
  99.             case "emptyChar":
  100.             case "progressChar":
  101.             case "formatString":
  102.             case "fractionFormat":
  103.             case "actFormat":
  104.             case "maxFormat":
  105.                 if is_string$value === false || strlen$value )
  106.                 {
  107.                     throw new ezcBaseValueException$key$value'string, not empty' );
  108.                 }
  109.                 break;
  110.             case "width":
  111.                 if !is_int$value || $value )
  112.                 {
  113.                     throw new ezcBaseValueException$key$value'int >= 5' );
  114.                 }
  115.                 break;
  116.             case "redrawFrequency":
  117.             case "step":
  118.                 if ( ( !is_int$value && !is_float$value ) ) || $value )
  119.                 {
  120.                     throw new ezcBaseValueException$key$value'int > 0' );
  121.                 }
  122.                 break;
  123.             case 'minVerbosity':
  124.                 if !is_int$value || $value )
  125.                 {
  126.                     throw new ezcBaseValueException$key$value'int >= 0' );
  127.                 }
  128.                 break;
  129.             case 'maxVerbosity':
  130.                 if ( ( !is_int$value || $value && $value !== false )
  131.                 {
  132.                     throw new ezcBaseValueException$key$value'int >= 0 or false' );
  133.                 }
  134.                 break;
  135.             default:
  136.                 throw new ezcBasePropertyNotFoundException$key );
  137.         }
  138.         $this->properties[$key$value;
  139.     }
  140. }
  141.  
  142. ?>
Documentation generated by phpDocumentor 1.4.3