FileSpecificCodeSample.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\FixerDefinition;
  13. /**
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. *
  16. * @internal
  17. */
  18. final class FileSpecificCodeSample implements FileSpecificCodeSampleInterface
  19. {
  20. private CodeSampleInterface $codeSample;
  21. private \SplFileInfo $splFileInfo;
  22. /**
  23. * @param null|array<string, mixed> $configuration
  24. */
  25. public function __construct(
  26. string $code,
  27. \SplFileInfo $splFileInfo,
  28. ?array $configuration = null
  29. ) {
  30. $this->codeSample = new CodeSample($code, $configuration);
  31. $this->splFileInfo = $splFileInfo;
  32. }
  33. public function getCode(): string
  34. {
  35. return $this->codeSample->getCode();
  36. }
  37. public function getConfiguration(): ?array
  38. {
  39. return $this->codeSample->getConfiguration();
  40. }
  41. public function getSplFileInfo(): \SplFileInfo
  42. {
  43. return $this->splFileInfo;
  44. }
  45. }