File tree Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Expand file tree Collapse file tree 3 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -21,4 +21,25 @@ public static function makeSchema()
21
21
$ schema ->setConstraint ($ properties );
22
22
return $ schema ;
23
23
}
24
+
25
+ /**
26
+ * @param $data
27
+ * @return static
28
+ * @throws \Yaoi\Schema\Exception
29
+ */
30
+ public static function import ($ data )
31
+ {
32
+ static $ schemas = array ();
33
+ return static ::makeSchema ()->import ($ data );
34
+ }
35
+
36
+ /**
37
+ * @param $data
38
+ * @return mixed
39
+ * @throws \Yaoi\Schema\Exception
40
+ */
41
+ public static function export ($ data )
42
+ {
43
+ return static ::makeSchema ()->export ($ data );
44
+ }
24
45
}
Original file line number Diff line number Diff line change 7
7
use Yaoi \Schema \Schema ;
8
8
use Yaoi \Schema \Structure \ClassStructure ;
9
9
10
- /**
11
- * @method import
12
- */
13
10
class LevelOneClass extends ClassStructure
14
11
{
15
12
/**
Original file line number Diff line number Diff line change @@ -16,16 +16,18 @@ protected function deepSchema()
16
16
return $ schema ;
17
17
}
18
18
19
- public function testImport ()
19
+ public function testImportClass ()
20
20
{
21
- $ object = $ this -> deepSchema ()-> import ( array (
21
+ $ data = array (
22
22
'level1 ' => array (
23
23
'level2 ' => array (
24
24
'level3 ' => 123 // integer required
25
25
),
26
26
),
27
- ));
27
+ );
28
+ $ object = LevelOneClass::import ($ data );
28
29
$ this ->assertSame (123 , $ object ->level1 ->level2 ->level3 );
30
+ $ this ->assertSame ($ data , LevelOneClass::export ($ object ));
29
31
}
30
32
31
33
You can’t perform that action at this time.
0 commit comments