Exemple #1
0
 /**
  * Set the value of an inaccessible property.
  *
  * @param string $name  The name of the property.
  * @param mixed  $value The value of the property.
  *
  * @return void
  * @throws RuntimeException If the setting name is invalid.
  */
 public function __set($name, $value)
 {
     if (array_key_exists($name, $this->settings) === false) {
         throw new RuntimeException("Can't __set() {$name}; setting doesn't exist");
     }
     switch ($name) {
         case 'reportWidth':
             // Support auto terminal width.
             if ($value === 'auto' && preg_match('|\\d+ (\\d+)|', shell_exec('stty size 2>&1'), $matches) === 1) {
                 $value = (int) $matches[1];
             } else {
                 $value = (int) $value;
             }
             break;
         case 'standards':
             $cleaned = array();
             // Check if the standard name is valid, or if the case is invalid.
             $installedStandards = Util\Standards::getInstalledStandards();
             foreach ($value as $standard) {
                 foreach ($installedStandards as $validStandard) {
                     if (strtolower($standard) === strtolower($validStandard)) {
                         $standard = $validStandard;
                         break;
                     }
                 }
                 $cleaned[] = $standard;
             }
             $value = $cleaned;
             break;
         default:
             // No validation required.
             break;
     }
     //end switch
     $this->settings[$name] = $value;
 }