-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a distinction between writers and formatters #293
Comments
Currently the typical usage is <?php
final class CsvWriter extends CsvFormatter
{
public function __construct(
string $filename,
string $delimiter = ',',
string $enclosure = '"',
string $escape = '\\',
bool $showHeaders = true,
bool $withBom = false,
string $terminate = "\n"
) {
// trigger deprecation here
return parent::__construct(
new FileWriter($filename)
$delimiter,
$enclosure,
$escape,
$showHeaders,
$terminate,
$withBom
);
}
} or the other way around with |
You could also only implement the WriterInterface, and implement both new classes. So both Formatters and Writers can be considered final classes. final class CsvWriter implements WriterInterface
{
private $writer;
private $formatter;
public function __construct(
string $filename,
string $delimiter = ',',
string $enclosure = '"',
string $escape = '\\',
bool $showHeaders = true,
bool $withBom = false,
string $terminate = "\n"
) {
$this->writer = new FileWriter($filename);
$this->formatter = new CsvFormatter(
$delimiter,
$enclosure,
$escape,
$showHeaders,
$withBom,
$terminate
);
}
public function open()
{
// implement logic
}
public function write(array $data)
{
// implement logic
}
public function close()
{
// implement logic
}
} |
Even better! If you feel up to it please submit a pull request with only the CSVFormatter and the FileWriter, and necessary changes in other classes (like the |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
I agree. We should have a more consistent mechanism to compose the required combination between formatters and writers. Currently, we have cases like #648, where we are using the source to provide arbitrary formats. At the same time, we also have dedicated formatters like If I'm not misunderstanding the purpose of these formatters, we could replace the arbitrary options mentioned above by formatters like |
Feature Request
Right now the Writers are actually Formatters and Writers in one. It would be much nicer to have Formatters and Writers. For example:
Formatters
Writers
This way the exporter component can be used for more usecases
The text was updated successfully, but these errors were encountered: