AbstractFixer.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS;
  11. /**
  12. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  13. */
  14. abstract class AbstractFixer implements FixerInterface
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function getLevel()
  20. {
  21. static $map = array(
  22. 'PSR0' => FixerInterface::PSR0_LEVEL,
  23. 'PSR1' => FixerInterface::PSR1_LEVEL,
  24. 'PSR2' => FixerInterface::PSR2_LEVEL,
  25. 'Symfony' => FixerInterface::SYMFONY_LEVEL,
  26. 'Contrib' => FixerInterface::CONTRIB_LEVEL,
  27. );
  28. $level = current(explode('\\', substr(get_called_class(), strlen(__NAMESPACE__.'\\Fixer\\'))));
  29. if (!isset($map[$level])) {
  30. throw new \LogicException('Can not determine Fixer level');
  31. }
  32. return $map[$level];
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function getName()
  38. {
  39. $nameParts = explode('\\', get_called_class());
  40. $name = substr(end($nameParts), 0, -strlen('Fixer'));
  41. return Utils::camelCaseToUnderscore($name);
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getPriority()
  47. {
  48. return 0;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function supports(\SplFileInfo $file)
  54. {
  55. return true;
  56. }
  57. }