Skip to content

Commit 3e9f6fb

Browse files
kynxbighappyface
authored andcommitted
Added SchemaStorageInterface (#339)
1 parent 9da41b0 commit 3e9f6fb

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

src/JsonSchema/Constraints/Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use JsonSchema\Exception\InvalidArgumentException;
1313
use JsonSchema\SchemaStorage;
14+
use JsonSchema\SchemaStorageInterface;
1415
use JsonSchema\Uri\UriRetriever;
1516
use JsonSchema\UriRetrieverInterface;
1617

@@ -68,7 +69,7 @@ class Factory
6869
* @param int $checkMode
6970
*/
7071
public function __construct(
71-
SchemaStorage $schemaStorage = null,
72+
SchemaStorageInterface $schemaStorage = null,
7273
UriRetrieverInterface $uriRetriever = null,
7374
$checkMode = Constraint::CHECK_MODE_NORMAL
7475
) {

src/JsonSchema/SchemaStorage.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use JsonSchema\Uri\UriResolver;
99
use JsonSchema\Uri\UriRetriever;
1010

11-
class SchemaStorage
11+
class SchemaStorage implements SchemaStorageInterface
1212
{
1313
protected $uriRetriever;
1414
protected $uriResolver;
@@ -39,8 +39,7 @@ public function getUriResolver()
3939
}
4040

4141
/**
42-
* @param string $id
43-
* @param object $schema
42+
* {@inheritdoc}
4443
*/
4544
public function addSchema($id, $schema = null)
4645
{
@@ -58,8 +57,7 @@ public function addSchema($id, $schema = null)
5857
}
5958

6059
/**
61-
* @param string $id
62-
* @return object
60+
* {@inheritdoc}
6361
*/
6462
public function getSchema($id)
6563
{
@@ -70,6 +68,9 @@ public function getSchema($id)
7068
return $this->schemas[$id];
7169
}
7270

71+
/**
72+
* {@inheritdoc}
73+
*/
7374
public function resolveRef($ref)
7475
{
7576
$jsonPointer = new JsonPointer($ref);
@@ -93,8 +94,7 @@ public function resolveRef($ref)
9394
}
9495

9596
/**
96-
* @param $refSchema
97-
* @return object
97+
* {@inheritdoc}
9898
*/
9999
public function resolveRefSchema($refSchema)
100100
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace JsonSchema;
4+
5+
interface SchemaStorageInterface
6+
{
7+
/**
8+
* Adds schema with given identifier
9+
* @param string $id
10+
* @param object $schema
11+
*/
12+
public function addSchema($id, $schema = null);
13+
14+
/**
15+
* Returns schema for given identifier, or null if it does not exist
16+
* @param string $id
17+
* @return object
18+
*/
19+
public function getSchema($id);
20+
21+
/**
22+
* Returns schema for given reference with all sub-references resolved
23+
* @param string $ref
24+
* @return object
25+
*/
26+
public function resolveRef($ref);
27+
28+
/**
29+
* Returns schema referenced by '$ref' property
30+
* @param mixed $refSchema
31+
* @return object
32+
*/
33+
public function resolveRefSchema($refSchema);
34+
}

0 commit comments

Comments
 (0)