1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace OpenSearch;
6:
7: use OpenSearch\Endpoints\AbstractEndpoint;
8:
9: // @phpstan-ignore classConstant.deprecatedClass
10: @trigger_error(LegacyEndpointFactory::class . ' is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
11:
12: /**
13: * Provides a endpoint factory using a legacy callable.
14: *
15: * @deprecated in 2.4.0 and will be removed in 3.0.0. Use PsrTransport instead.
16: */
17: class LegacyEndpointFactory implements EndpointFactoryInterface
18: {
19: /**
20: * The endpoints callable.
21: *
22: * @var callable
23: */
24: protected $endpoints;
25:
26: public function __construct(callable $endpoints)
27: {
28: $this->endpoints = $endpoints;
29: }
30:
31: /**
32: * {@inheritdoc}
33: */
34: public function getEndpoint(string $class): AbstractEndpoint
35: {
36: // We need to strip the base namespace from the class name for BC.
37: $class = str_replace('OpenSearch\\Endpoints\\', '', $class);
38: $endpointBuilder = $this->endpoints;
39: return $endpointBuilder($class);
40: }
41:
42: }
43: