LimeOutputFactory.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Lime framework.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. class LimeOutputFactory
  12. {
  13. protected
  14. $options = array();
  15. public function __construct(array $options)
  16. {
  17. $this->options = array_merge(array(
  18. 'serialize' => false,
  19. 'force_colors' => false,
  20. 'base_dir' => null,
  21. ), $options);
  22. }
  23. public function create($name)
  24. {
  25. $colorizer = LimeColorizer::isSupported() || $this->options['force_colors'] ? new LimeColorizer() : null;
  26. $printer = new LimePrinter($colorizer);
  27. switch ($name)
  28. {
  29. case 'raw':
  30. return new LimeOutputRaw();
  31. case 'xml':
  32. return new LimeOutputXml();
  33. case 'array':
  34. return new LimeOutputArray($this->options['serialize']);
  35. case 'summary':
  36. return new LimeOutputConsoleSummary($printer, $this->options);
  37. case 'tap':
  38. default:
  39. return new LimeOutputTap($printer, $this->options);
  40. }
  41. }
  42. }