File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ final class Structure implements Schema
3131
3232
3333 /**
34- * @param Schema[] $items
34+ * @param Schema[] $shape
3535 */
36- public function __construct (array $ items )
36+ public function __construct (array $ shape )
3737 {
38- (function (Schema ...$ items ) {})(...array_values ($ items ));
39- $ this ->items = $ items ;
38+ (function (Schema ...$ items ) {})(...array_values ($ shape ));
39+ $ this ->items = $ shape ;
4040 $ this ->castTo ('object ' );
4141 $ this ->required = true ;
4242 }
@@ -83,6 +83,12 @@ public function extend(array|self $shape): self
8383 }
8484
8585
86+ public function getShape (): array
87+ {
88+ return $ this ->items ;
89+ }
90+
91+
8692 /********************* processing ****************d*g**/
8793
8894
Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ public static function anyOf(mixed ...$set): AnyOf
5656
5757
5858 /**
59- * @param Schema[] $items
59+ * @param Schema[] $shape
6060 */
61- public static function structure (array $ items ): Structure
61+ public static function structure (array $ shape ): Structure
6262 {
63- return new Structure ($ items );
63+ return new Structure ($ shape );
6464 }
6565
6666
Original file line number Diff line number Diff line change @@ -516,3 +516,11 @@ test('extend', function () {
516516 $ schema ->extend (Expect::structure (['a ' => Expect::int (), 'c ' => Expect::int ()])),
517517 );
518518});
519+
520+
521+ test ('getShape ' , function () {
522+ Assert::equal (
523+ ['a ' => Expect::int (), 'b ' => Expect::string ()],
524+ Expect::structure (['a ' => Expect::int (), 'b ' => Expect::string ()])->getShape (),
525+ );
526+ });
You can’t perform that action at this time.
0 commit comments