| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace WordPress\AiClientDependencies\Http\Discovery; 4 5 use WordPress\AiClientDependencies\Http\Discovery\Exception\DiscoveryFailedException; 6 use WordPress\AiClientDependencies\Http\Discovery\Exception\NotFoundException as RealNotFoundException; 7 use WordPress\AiClientDependencies\Psr\Http\Message\RequestFactoryInterface; 8 use WordPress\AiClientDependencies\Psr\Http\Message\ResponseFactoryInterface; 9 use WordPress\AiClientDependencies\Psr\Http\Message\ServerRequestFactoryInterface; 10 use WordPress\AiClientDependencies\Psr\Http\Message\StreamFactoryInterface; 11 use WordPress\AiClientDependencies\Psr\Http\Message\UploadedFileFactoryInterface; 12 use WordPress\AiClientDependencies\Psr\Http\Message\UriFactoryInterface; 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 RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e); 23 } 24 /** 25 * @return RequestFactoryInterface 26 * 27 * @throws RealNotFoundException 28 */ 29 public static function findRequestFactory() 30 { 31 try { 32 $messageFactory = static::findOneByType(RequestFactoryInterface::class); 33 } catch (DiscoveryFailedException $e) { 34 throw self::createException('request factory', $e); 35 } 36 return static::instantiateClass($messageFactory); 37 } 38 /** 39 * @return ResponseFactoryInterface 40 * 41 * @throws RealNotFoundException 42 */ 43 public static function findResponseFactory() 44 { 45 try { 46 $messageFactory = static::findOneByType(ResponseFactoryInterface::class); 47 } catch (DiscoveryFailedException $e) { 48 throw self::createException('response factory', $e); 49 } 50 return static::instantiateClass($messageFactory); 51 } 52 /** 53 * @return ServerRequestFactoryInterface 54 * 55 * @throws RealNotFoundException 56 */ 57 public static function findServerRequestFactory() 58 { 59 try { 60 $messageFactory = static::findOneByType(ServerRequestFactoryInterface::class); 61 } catch (DiscoveryFailedException $e) { 62 throw self::createException('server request factory', $e); 63 } 64 return static::instantiateClass($messageFactory); 65 } 66 /** 67 * @return StreamFactoryInterface 68 * 69 * @throws RealNotFoundException 70 */ 71 public static function findStreamFactory() 72 { 73 try { 74 $messageFactory = static::findOneByType(StreamFactoryInterface::class); 75 } catch (DiscoveryFailedException $e) { 76 throw self::createException('stream factory', $e); 77 } 78 return static::instantiateClass($messageFactory); 79 } 80 /** 81 * @return UploadedFileFactoryInterface 82 * 83 * @throws RealNotFoundException 84 */ 85 public static function findUploadedFileFactory() 86 { 87 try { 88 $messageFactory = static::findOneByType(UploadedFileFactoryInterface::class); 89 } catch (DiscoveryFailedException $e) { 90 throw self::createException('uploaded file factory', $e); 91 } 92 return static::instantiateClass($messageFactory); 93 } 94 /** 95 * @return UriFactoryInterface 96 * 97 * @throws RealNotFoundException 98 */ 99 public static function findUriFactory() 100 { 101 try { 102 $messageFactory = static::findOneByType(UriFactoryInterface::class); 103 } catch (DiscoveryFailedException $e) { 104 throw self::createException('url factory', $e); 105 } 106 return static::instantiateClass($messageFactory); 107 } 108 /** 109 * @return UriFactoryInterface 110 * 111 * @throws RealNotFoundException 112 * 113 * @deprecated This will be removed in 2.0. Consider using the findUriFactory() method. 114 */ 115 public static function findUrlFactory() 116 { 117 return static::findUriFactory(); 118 } 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jun 13 09:38:55 2026 | Cross-referenced by PHPXref |