PHPUnit_Util_Printer::__construct PHP Method

__construct() public method

Constructor.
public __construct ( mixed $out = NULL )
$out mixed
    public function __construct($out = NULL)
    {
        if ($out !== NULL) {
            if (is_string($out)) {
                if (strpos($out, 'socket://') === 0) {
                    $out = explode(':', str_replace('socket://', '', $out));
                    if (sizeof($out) != 2) {
                        throw new InvalidArgumentException();
                    }
                    $this->out = fsockopen($out[0], $out[1]);
                } else {
                    if (strpos($out, 'php://') === FALSE && !is_dir(dirname($out))) {
                        mkdir(dirname($out), 0777, TRUE);
                    }
                    $this->out = fopen($out, 'wt');
                }
                $this->outTarget = $out;
            } else {
                $this->out = $out;
            }
        }
    }

Usage Example

 /**
  * Constructor
  *
  * Parameter can be set in the phpunit xml configuration file:
  * <code>
  * <listeners>
  * 		<listener class="..." file="...">
  *			<arguments>
  * 				<string>...</string><!-- targetFile -->
  *
  * 				<string>...</string><!-- directory -->
  *
  * 				<array>
  * 					<element key="js/handle.gif">
  * 						<string>###MENTA_ROOTDIR###/PHPUnit/Listener/Resources/Templates/files/handle.gif</string>
  *					</element>
  * 					<element key="js/jquery.beforeafter-1.4.min.js">
  * 						<string>###MENTA_ROOTDIR###/PHPUnit/Listener/Resources/Templates/files/jquery.beforeafter-1.4.min.js</string>
  *					</element>
  *					<!-- ... -->
  * 				</array>
  * 			</arguments>
  * 		</listener>
  * </listeners>
  * </code>
  *
  * @param string $targetFile
  * @param string $templateFile
  * @param array $additionalFiles
  * @throws Exception
  * @author Fabrizio Branca
  */
 public function __construct($targetFile = NULL, $templateFile = NULL, array $additionalFiles = NULL)
 {
     if (!is_null($targetFile)) {
         $this->targetFile = $targetFile;
         $this->targetFile = Menta_Util_Div::replaceWithEnvironmentVariables($this->targetFile);
     }
     $dir = dirname($this->targetFile);
     if (!is_dir($dir)) {
         throw new Exception("Target dir '{$dir}' does not exist");
     }
     // clean target dir
     foreach (glob($dir . "/*") as $file) {
         if (!is_dir($file)) {
             unlink($file);
         }
     }
     if (!is_null($templateFile)) {
         $this->templateFile = $templateFile;
     }
     $this->templateFile = str_replace('###MENTA_ROOTDIR###', MENTA_ROOTDIR, $this->templateFile);
     if (empty($this->templateFile)) {
         throw new Exception('No template file defined');
     }
     if (!is_null($additionalFiles)) {
         $this->additionalFiles = $additionalFiles;
     }
     parent::__construct($this->targetFile);
 }
All Usage Examples Of PHPUnit_Util_Printer::__construct