PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / php-http / discovery / src / Psr17FactoryDiscovery.php
ameliabooking / vendor / php-http / discovery / src Last commit date
Exception 3 years ago Strategy 6 months ago ClassDiscovery.php 3 years ago Exception.php 3 years ago HttpAsyncClientDiscovery.php 3 years ago HttpClientDiscovery.php 3 years ago MessageFactoryDiscovery.php 3 years ago NotFoundException.php 11 months ago Psr17FactoryDiscovery.php 6 months ago Psr18ClientDiscovery.php 11 months ago StreamFactoryDiscovery.php 3 years ago UriFactoryDiscovery.php 3 years ago
Psr17FactoryDiscovery.php
125 lines
1 <?php
2
3 namespace AmeliaHttp\Discovery;
4
5 use AmeliaHttp\Discovery\Exception\DiscoveryFailedException;
6 use AmeliaVendor\Psr\Http\Message\RequestFactoryInterface;
7 use AmeliaVendor\Psr\Http\Message\ResponseFactoryInterface;
8 use AmeliaVendor\Psr\Http\Message\ServerRequestFactoryInterface;
9 use AmeliaVendor\Psr\Http\Message\StreamFactoryInterface;
10 use AmeliaVendor\Psr\Http\Message\UploadedFileFactoryInterface;
11 use AmeliaVendor\Psr\Http\Message\UriFactoryInterface;
12
13 /**
14 * Finds PSR-17 factories.
15 *
16 * @author Tobias Nyholm <tobias.nyholm@gmail.com>
17 */
18 final class Psr17FactoryDiscovery extends ClassDiscovery
19 {
20 private static function createException($type, Exception $e)
21 {
22 return new \AmeliaHttp\Discovery\Exception\NotFoundException(
23 'No PSR-17 '.$type.' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation',
24 0,
25 $e
26 );
27 }
28
29 /**
30 * @return RequestFactoryInterface
31 *
32 * @throws Exception\NotFoundException
33 */
34 public static function findRequestFactory()
35 {
36 try {
37 $messageFactory = static::findOneByType(RequestFactoryInterface::class);
38 } catch (DiscoveryFailedException $e) {
39 throw self::createException('request factory', $e);
40 }
41
42 return static::instantiateClass($messageFactory);
43 }
44
45 /**
46 * @return ResponseFactoryInterface
47 *
48 * @throws Exception\NotFoundException
49 */
50 public static function findResponseFactory()
51 {
52 try {
53 $messageFactory = static::findOneByType(ResponseFactoryInterface::class);
54 } catch (DiscoveryFailedException $e) {
55 throw self::createException('response factory', $e);
56 }
57
58 return static::instantiateClass($messageFactory);
59 }
60
61 /**
62 * @return ServerRequestFactoryInterface
63 *
64 * @throws Exception\NotFoundException
65 */
66 public static function findServerRequestFactory()
67 {
68 try {
69 $messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
70 } catch (DiscoveryFailedException $e) {
71 throw self::createException('server request factory', $e);
72 }
73
74 return static::instantiateClass($messageFactory);
75 }
76
77 /**
78 * @return StreamFactoryInterface
79 *
80 * @throws Exception\NotFoundException
81 */
82 public static function findStreamFactory()
83 {
84 try {
85 $messageFactory = static::findOneByType(StreamFactoryInterface::class);
86 } catch (DiscoveryFailedException $e) {
87 throw self::createException('stream factory', $e);
88 }
89
90 return static::instantiateClass($messageFactory);
91 }
92
93 /**
94 * @return UploadedFileFactoryInterface
95 *
96 * @throws Exception\NotFoundException
97 */
98 public static function findUploadedFileFactory()
99 {
100 try {
101 $messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
102 } catch (DiscoveryFailedException $e) {
103 throw self::createException('uploaded file factory', $e);
104 }
105
106 return static::instantiateClass($messageFactory);
107 }
108
109 /**
110 * @return UriFactoryInterface
111 *
112 * @throws Exception\NotFoundException
113 */
114 public static function findUrlFactory()
115 {
116 try {
117 $messageFactory = static::findOneByType(UriFactoryInterface::class);
118 } catch (DiscoveryFailedException $e) {
119 throw self::createException('url factory', $e);
120 }
121
122 return static::instantiateClass($messageFactory);
123 }
124 }
125