1313 * unique identifier, display name, and type (cloud, server, or client).
1414 *
1515 * @since 0.1.0
16+ * @since 1.2.0 Added optional description property.
1617 *
1718 * @phpstan-type ProviderMetadataArrayShape array{
1819 * id: string,
1920 * name: string,
21+ * description?: ?string,
2022 * type: string,
2123 * credentialsUrl?: ?string,
2224 * authenticationMethod?: ?string
@@ -28,6 +30,7 @@ class ProviderMetadata extends AbstractDataTransferObject
2830{
2931 public const KEY_ID = 'id ' ;
3032 public const KEY_NAME = 'name ' ;
33+ public const KEY_DESCRIPTION = 'description ' ;
3134 public const KEY_TYPE = 'type ' ;
3235 public const KEY_CREDENTIALS_URL = 'credentialsUrl ' ;
3336 public const KEY_AUTHENTICATION_METHOD = 'authenticationMethod ' ;
@@ -39,6 +42,10 @@ class ProviderMetadata extends AbstractDataTransferObject
3942 * @var string The provider's display name.
4043 */
4144 protected string $ name ;
45+ /**
46+ * @var string|null The provider's description.
47+ */
48+ protected ?string $ description ;
4249 /**
4350 * @var ProviderTypeEnum The provider type.
4451 */
@@ -55,17 +62,20 @@ class ProviderMetadata extends AbstractDataTransferObject
5562 * Constructor.
5663 *
5764 * @since 0.1.0
65+ * @since 1.2.0 Added optional $description parameter.
5866 *
5967 * @param string $id The provider's unique identifier.
6068 * @param string $name The provider's display name.
6169 * @param ProviderTypeEnum $type The provider type.
6270 * @param string|null $credentialsUrl The URL where users can get credentials.
6371 * @param RequestAuthenticationMethod|null $authenticationMethod The authentication method.
72+ * @param string|null $description The provider's description.
6473 */
65- public function __construct (string $ id , string $ name , ProviderTypeEnum $ type , ?string $ credentialsUrl = null , ?RequestAuthenticationMethod $ authenticationMethod = null )
74+ public function __construct (string $ id , string $ name , ProviderTypeEnum $ type , ?string $ credentialsUrl = null , ?RequestAuthenticationMethod $ authenticationMethod = null , ? string $ description = null )
6675 {
6776 $ this ->id = $ id ;
6877 $ this ->name = $ name ;
78+ $ this ->description = $ description ;
6979 $ this ->type = $ type ;
7080 $ this ->credentialsUrl = $ credentialsUrl ;
7181 $ this ->authenticationMethod = $ authenticationMethod ;
@@ -92,6 +102,17 @@ public function getName(): string
92102 {
93103 return $ this ->name ;
94104 }
105+ /**
106+ * Gets the provider's description.
107+ *
108+ * @since 1.2.0
109+ *
110+ * @return string|null The provider description.
111+ */
112+ public function getDescription (): ?string
113+ {
114+ return $ this ->description ;
115+ }
95116 /**
96117 * Gets the provider type.
97118 *
@@ -129,30 +150,33 @@ public function getAuthenticationMethod(): ?RequestAuthenticationMethod
129150 * {@inheritDoc}
130151 *
131152 * @since 0.1.0
153+ * @since 1.2.0 Added description to schema.
132154 */
133155 public static function getJsonSchema (): array
134156 {
135- return ['type ' => 'object ' , 'properties ' => [self ::KEY_ID => ['type ' => 'string ' , 'description ' => 'The provider \'s unique identifier. ' ], self ::KEY_NAME => ['type ' => 'string ' , 'description ' => 'The provider \'s display name. ' ], self ::KEY_TYPE => ['type ' => 'string ' , 'enum ' => ProviderTypeEnum::getValues (), 'description ' => 'The provider type (cloud, server, or client). ' ], self ::KEY_CREDENTIALS_URL => ['type ' => 'string ' , 'description ' => 'The URL where users can get credentials. ' ], self ::KEY_AUTHENTICATION_METHOD => ['type ' => ['string ' , 'null ' ], 'enum ' => array_merge (RequestAuthenticationMethod::getValues (), [null ]), 'description ' => 'The authentication method. ' ]], 'required ' => [self ::KEY_ID , self ::KEY_NAME , self ::KEY_TYPE ]];
157+ return ['type ' => 'object ' , 'properties ' => [self ::KEY_ID => ['type ' => 'string ' , 'description ' => 'The provider \'s unique identifier. ' ], self ::KEY_NAME => ['type ' => 'string ' , 'description ' => 'The provider \'s display name. ' ], self ::KEY_DESCRIPTION => [ ' type ' => ' string ' , ' description ' => ' The provider \' s description. ' ], self :: KEY_TYPE => ['type ' => 'string ' , 'enum ' => ProviderTypeEnum::getValues (), 'description ' => 'The provider type (cloud, server, or client). ' ], self ::KEY_CREDENTIALS_URL => ['type ' => 'string ' , 'description ' => 'The URL where users can get credentials. ' ], self ::KEY_AUTHENTICATION_METHOD => ['type ' => ['string ' , 'null ' ], 'enum ' => array_merge (RequestAuthenticationMethod::getValues (), [null ]), 'description ' => 'The authentication method. ' ]], 'required ' => [self ::KEY_ID , self ::KEY_NAME , self ::KEY_TYPE ]];
136158 }
137159 /**
138160 * {@inheritDoc}
139161 *
140162 * @since 0.1.0
163+ * @since 1.2.0 Added description to output.
141164 *
142165 * @return ProviderMetadataArrayShape
143166 */
144167 public function toArray (): array
145168 {
146- return [self ::KEY_ID => $ this ->id , self ::KEY_NAME => $ this ->name , self ::KEY_TYPE => $ this ->type ->value , self ::KEY_CREDENTIALS_URL => $ this ->credentialsUrl , self ::KEY_AUTHENTICATION_METHOD => $ this ->authenticationMethod ? $ this ->authenticationMethod ->value : null ];
169+ return [self ::KEY_ID => $ this ->id , self ::KEY_NAME => $ this ->name , self ::KEY_DESCRIPTION => $ this -> description , self :: KEY_TYPE => $ this ->type ->value , self ::KEY_CREDENTIALS_URL => $ this ->credentialsUrl , self ::KEY_AUTHENTICATION_METHOD => $ this ->authenticationMethod ? $ this ->authenticationMethod ->value : null ];
147170 }
148171 /**
149172 * {@inheritDoc}
150173 *
151174 * @since 0.1.0
175+ * @since 1.2.0 Added description support.
152176 */
153177 public static function fromArray (array $ array ): self
154178 {
155179 static ::validateFromArrayData ($ array , [self ::KEY_ID , self ::KEY_NAME , self ::KEY_TYPE ]);
156- return new self ($ array [self ::KEY_ID ], $ array [self ::KEY_NAME ], ProviderTypeEnum::from ($ array [self ::KEY_TYPE ]), $ array [self ::KEY_CREDENTIALS_URL ] ?? null , isset ($ array [self ::KEY_AUTHENTICATION_METHOD ]) ? RequestAuthenticationMethod::from ($ array [self ::KEY_AUTHENTICATION_METHOD ]) : null );
180+ return new self ($ array [self ::KEY_ID ], $ array [self ::KEY_NAME ], ProviderTypeEnum::from ($ array [self ::KEY_TYPE ]), $ array [self ::KEY_CREDENTIALS_URL ] ?? null , isset ($ array [self ::KEY_AUTHENTICATION_METHOD ]) ? RequestAuthenticationMethod::from ($ array [self ::KEY_AUTHENTICATION_METHOD ]) : null , $ array [ self :: KEY_DESCRIPTION ] ?? null );
157181 }
158182}
0 commit comments