forked from cebe/php-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReader.php
More file actions
29 lines (24 loc) · 667 Bytes
/
Reader.php
File metadata and controls
29 lines (24 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* @copyright Copyright (c) 2018 Carsten Brandt <mail@cebe.cc> and contributors
* @license https://github.com/cebe/php-openapi/blob/master/LICENSE
*/
namespace cebe\openapi;
use cebe\openapi\spec\OpenApi;
use Symfony\Component\Yaml\Yaml;
/**
*
*
* @author Carsten Brandt <mail@cebe.cc>
*/
class Reader
{
public static function readFromJson(string $json, string $baseType = OpenApi::class): SpecBaseObject
{
return new $baseType(json_decode($json, true));
}
public static function readFromYaml(string $yaml, string $baseType = OpenApi::class): SpecBaseObject
{
return new $baseType(Yaml::parse($yaml));
}
}