ServiceFactoryRegistration.php 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\AppFramework\Bootstrap;
  8. /**
  9. * @psalm-immutable
  10. */
  11. class ServiceFactoryRegistration extends ARegistration {
  12. /**
  13. * @var string
  14. * @psalm-var string|class-string
  15. */
  16. private $name;
  17. /**
  18. * @var callable
  19. * @psalm-var callable(\Psr\Container\ContainerInterface): mixed
  20. */
  21. private $factory;
  22. /** @var bool */
  23. private $shared;
  24. public function __construct(string $appId,
  25. string $alias,
  26. callable $target,
  27. bool $shared) {
  28. parent::__construct($appId);
  29. $this->name = $alias;
  30. $this->factory = $target;
  31. $this->shared = $shared;
  32. }
  33. public function getName(): string {
  34. return $this->name;
  35. }
  36. /**
  37. * @psalm-return callable(\Psr\Container\ContainerInterface): mixed
  38. */
  39. public function getFactory(): callable {
  40. return $this->factory;
  41. }
  42. public function isShared(): bool {
  43. return $this->shared;
  44. }
  45. }