mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-09-05 13:05:34 +01:00
Fix output for tests to pass again
This commit is contained in:
parent
6d6f5596ce
commit
b9b41aa437
3 changed files with 37 additions and 9 deletions
|
@ -19,10 +19,21 @@ class Builder
|
|||
*/
|
||||
private $outputFile;
|
||||
|
||||
public function __construct(array $filters, $outputFile = 'filters.xml') {
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $writeFile;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $xml;
|
||||
|
||||
public function __construct(array $filters, $outputFile = 'filters.xml', $writeFile = true) {
|
||||
$this->filesystem = new Filesystem();
|
||||
$this->filters = $filters;
|
||||
$this->outputFile = $outputFile;
|
||||
$this->writeFile = $writeFile;
|
||||
|
||||
$this->build();
|
||||
}
|
||||
|
@ -32,6 +43,16 @@ class Builder
|
|||
return $this->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the generated XML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXml()
|
||||
{
|
||||
return $this->xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build XML for a set of filters.
|
||||
*
|
||||
|
@ -46,9 +67,11 @@ class Builder
|
|||
return $this->buildEntry($items);
|
||||
})->implode(PHP_EOL);
|
||||
|
||||
$content = collect([$prefix, $xml, $suffix])->implode(PHP_EOL);
|
||||
$this->xml = collect([$prefix, $xml, $suffix])->implode(PHP_EOL);
|
||||
|
||||
$this->filesystem->dumpFile($this->outputFile, $content);
|
||||
if ($this->writeFile) {
|
||||
$this->filesystem->dumpFile($this->outputFile, $this->xml);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue