WhitespacesFixerConfig.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. */
  16. final class WhitespacesFixerConfig
  17. {
  18. private string $indent;
  19. private string $lineEnding;
  20. public function __construct(string $indent = ' ', string $lineEnding = "\n")
  21. {
  22. if (!\in_array($indent, [' ', ' ', "\t"], true)) {
  23. throw new \InvalidArgumentException('Invalid "indent" param, expected tab or two or four spaces.');
  24. }
  25. if (!\in_array($lineEnding, ["\n", "\r\n"], true)) {
  26. throw new \InvalidArgumentException('Invalid "lineEnding" param, expected "\n" or "\r\n".');
  27. }
  28. $this->indent = $indent;
  29. $this->lineEnding = $lineEnding;
  30. }
  31. public function getIndent(): string
  32. {
  33. return $this->indent;
  34. }
  35. public function getLineEnding(): string
  36. {
  37. return $this->lineEnding;
  38. }
  39. }