1
0

ObjectParameter.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. declare(strict_types = 1);
  3. /*
  4. * This file is part of the Symfony package.
  5. *
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @copyright 2022 Carl Schwan <carl@carlschwan.eu>
  12. *
  13. * @author Carl Schwan <carl@carlschwan.eu>
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. *
  16. * @license AGPL-3.0-or-later AND MIT
  17. *
  18. * This program is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License as
  20. * published by the Free Software Foundation, either version 3 of the
  21. * License, or (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU Affero General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU Affero General Public License
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. *
  31. */
  32. namespace OC\DB;
  33. final class ObjectParameter {
  34. private $object;
  35. private $error;
  36. private $stringable;
  37. private $class;
  38. /**
  39. * @param object $object
  40. */
  41. public function __construct($object, ?\Throwable $error) {
  42. $this->object = $object;
  43. $this->error = $error;
  44. $this->stringable = \is_callable([$object, '__toString']);
  45. $this->class = \get_class($object);
  46. }
  47. /**
  48. * @return object
  49. */
  50. public function getObject() {
  51. return $this->object;
  52. }
  53. public function getError(): ?\Throwable {
  54. return $this->error;
  55. }
  56. public function isStringable(): bool {
  57. return $this->stringable;
  58. }
  59. public function getClass(): string {
  60. return $this->class;
  61. }
  62. }