RiskyResource.php 595 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Nesk\Puphpeteer\Tests;
  3. use Nesk\Rialto\Exceptions\Node\FatalException as NodeFatalException;
  4. class RiskyResource
  5. {
  6. protected $value = null;
  7. protected $exception = null;
  8. public function __construct(callable $resourceRetriever) {
  9. try {
  10. $this->value = $resourceRetriever();
  11. } catch (NodeFatalException $exception) {
  12. $this->exception = $exception;
  13. }
  14. }
  15. public function value() {
  16. return $this->value;
  17. }
  18. public function exception(): ?NodeFatalException {
  19. return $this->exception;
  20. }
  21. }