/** * @throws BuildException */ private function validateProperties() { if ($this->fileToCheck === null && count($this->fileSets) === 0) { throw new BuildException('Missing either a nested fileset or the attribute "file" set.'); } if ($this->fileToCheck !== null) { if (!file_exists($this->fileToCheck)) { throw new BuildException("File to check doesn't exist."); } if (!$this->isFileSuffixSet($this->fileToCheck)) { throw new BuildException('Suffix of file to check is not defined in "suffixes" attribute.'); } if (count($this->fileSets) > 0) { throw new BuildException('Either use a nested fileset or "file" attribute; not both.'); } } if (count($this->suffixesToCheck) === 0) { throw new BuildException('No file suffix defined.'); } if (count($this->formatterElements) == 0) { if ($this->reportType === null) { throw new BuildException('No report type or formatters defined.'); } if ($this->reportType !== null && !in_array($this->reportType, $this->acceptedReportTypes)) { throw new BuildException('Unaccepted report type defined.'); } if ($this->reportType !== 'cli' && $this->reportDirectory === null) { throw new BuildException('No report output directory defined.'); } if ($this->reportDirectory !== null && !is_dir($this->reportDirectory)) { $reportOutputDir = new PhingFile($this->reportDirectory); $logMessage = "Report output directory doesn't exist, creating: " . $reportOutputDir->getAbsolutePath() . '.'; $this->log($logMessage); $reportOutputDir->mkdirs(); } if ($this->reportType !== 'cli') { $this->reportFileName .= '.' . $this->reportType; } $formatterElement = new PHPLocFormatterElement(); $formatterElement->setType($this->reportType); $formatterElement->setUseFile($this->reportDirectory !== null); $formatterElement->setToDir($this->reportDirectory); $formatterElement->setOutfile($this->reportFileName); $this->formatterElements[] = $formatterElement; } }