UnintentionallyCoveredCodeException.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of phpunit/php-code-coverage.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\CodeCoverage;
  11. use RuntimeException;
  12. final class UnintentionallyCoveredCodeException extends RuntimeException implements Exception
  13. {
  14. /**
  15. * @var array
  16. */
  17. private $unintentionallyCoveredUnits;
  18. public function __construct(array $unintentionallyCoveredUnits)
  19. {
  20. $this->unintentionallyCoveredUnits = $unintentionallyCoveredUnits;
  21. parent::__construct($this->toString());
  22. }
  23. public function getUnintentionallyCoveredUnits(): array
  24. {
  25. return $this->unintentionallyCoveredUnits;
  26. }
  27. private function toString(): string
  28. {
  29. $message = '';
  30. foreach ($this->unintentionallyCoveredUnits as $unit) {
  31. $message .= '- ' . $unit . "\n";
  32. }
  33. return $message;
  34. }
  35. }