Skip to content

Commit 4aa862a

Browse files
committed
pushing legacy to the future!
1 parent bc8ead2 commit 4aa862a

21 files changed

+163
-115
lines changed

src/Constraint/InvalidValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Yaoi\Schema\Constraint;
44

55

6-
use Yaoi\Schema\Exception;
6+
use Yaoi\Schema\InvalidValue;
77

8-
class InvalidValue extends Exception
8+
class InvalidValue extends InvalidValue
99
{
1010
}

src/Constraint/Properties.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Yaoi\Schema\Constraint;
44

5-
use Yaoi\Schema\Exception;
5+
use Yaoi\Schema\InvalidValue;
66
use Yaoi\Schema\MagicMap;
77
use Yaoi\Schema\Schema;
88
use Yaoi\Schema\SchemaLoader;
@@ -41,7 +41,7 @@ public static function create()
4141
* @param $data
4242
* @param ObjectItem $result
4343
* @param Schema|null $schema
44-
* @throws Exception
44+
* @throws InvalidValue
4545
* @throws \Exception
4646
* @deprecated move relevant code to Schema
4747
*/
@@ -72,7 +72,7 @@ public function import($data, ObjectItem $result, Schema $schema = null)
7272
if (!$found && null !== $additionalProperties) {
7373
$traceHelper->push()->addData(SchemaLoader::ADDITIONAL_PROPERTIES);
7474
if ($additionalProperties === false) {
75-
throw new Exception('Additional properties not allowed', Exception::INVALID_VALUE);
75+
throw new InvalidValue('Additional properties not allowed', InvalidValue::INVALID_VALUE);
7676
}
7777
$value = $additionalProperties->import($value);
7878
$traceHelper->pop();

src/Constraint/Ref.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Ref implements Constraint
88
{
9-
private $ref;
9+
public $ref;
1010
public function __construct($ref, Schema $schema)
1111
{
1212
$this->ref = $ref;

src/Exception/EnumException.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Yaoi\Schema\Exception;
4+
5+
use Yaoi\Schema\InvalidValue;
6+
7+
class EnumException extends InvalidValue
8+
{
9+
10+
}

src/Exception/LogicException.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Yaoi\Schema\Exception;
4+
5+
use Yaoi\Schema\InvalidValue;
6+
7+
class LogicException extends InvalidValue
8+
{
9+
10+
}

src/Exception/NumericException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Yaoi\Schema\Exception;
4+
5+
6+
use Yaoi\Schema\InvalidValue;
7+
8+
class NumericException extends InvalidValue
9+
{
10+
const MULTIPLE_OF = 1;
11+
const MAXIMUM = 2;
12+
const MINIMUM = 3;
13+
14+
}

src/Exception/ObjectException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Yaoi\Schema\Exception;
4+
5+
use Yaoi\Schema\InvalidValue;
6+
7+
class ObjectException extends InvalidValue
8+
{
9+
const REQUIRED = 1;
10+
const TOO_MANY = 2;
11+
const TOO_FEW = 3;
12+
const DEPENDENCY_MISSING = 4;
13+
14+
}

src/Exception/StringException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Yaoi\Schema\Exception;
4+
5+
6+
use Yaoi\Schema\InvalidValue;
7+
8+
class StringException extends InvalidValue
9+
{
10+
const TOO_SHORT = 1;
11+
const TOO_LONG = 2;
12+
const PATTERN_MISMATCH = 3;
13+
14+
}

src/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public static function toPregPattern($jsonPattern)
1818
}
1919

2020
if (false === $pattern) {
21-
throw new Exception('Failed to prepare preg pattern');
21+
throw new InvalidValue('Failed to prepare preg pattern');
2222
}
2323

2424
if (@preg_match($pattern, '') === false) {
25-
throw new Exception('Regex pattern is invalid: ' . $jsonPattern);
25+
throw new InvalidValue('Regex pattern is invalid: ' . $jsonPattern);
2626
}
2727

2828
return $pattern;

src/Exception.php renamed to src/InvalidValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Yaoi\Schema;
44

5-
class Exception extends \Exception
5+
class InvalidValue extends \Exception
66
{
77
const INVALID_VALUE = 1;
88
const NOT_IMPLEMENTED = 2;

0 commit comments

Comments
 (0)