/** * Factory a featureElement * * @return FeatureInterface */ public function factory($filename) { if (!file_exists($filename)) { throw new NotBuildableException(sprintf('File "%s" not found', $filename)); } $feature = $this->parser->parse(file_get_contents($filename), $filename); $proxy = new ModelGherkin($feature); $report = $this->reportRepository->getReportByFeature($proxy); return new ModelFeature($proxy, $report, $this->container); }
/** * Set the content of the feature * * @param string */ public function setContent($content) { // @tmp // @todo // don't use directly the DIC $filename = 'tmp-' . uniqid() . '.feature'; $path = $this->folder . $filename; file_put_contents($path, $content); $feature = $this->featureRepository->getFeatureByPath($filename); unlink($path); if ($feature === null) { throw new \Exception('Cannot set the content of the feature'); } $this->gherkinObject = $feature->getGherkin(); }
/** * Get the relative path of the given feature * * @param FeatureNode $node * @return type */ public function getRelativePath(FeatureInterface $node) { return str_replace($this->folder, '', $node->getFile()); }