Skip to content

Commit 4a743f6

Browse files
committed
Use config via factory checkMode instead of helper method
1 parent 6979b17 commit 4a743f6

File tree

3 files changed

+3
-38
lines changed

3 files changed

+3
-38
lines changed

src/JsonSchema/Constraints/Factory.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,4 @@ public function getCheckMode()
149149
{
150150
return $this->checkMode;
151151
}
152-
153-
/**
154-
* Update apply defaults setting in checkmode
155-
*
156-
* @param boolean $applyDefaults
157-
*/
158-
public function setApplyDefaults($applyDefaults = true)
159-
{
160-
if ($applyDefaults) {
161-
$this->checkMode |= Constraint::CHECK_MODE_APPLY_DEFAULTS;
162-
} else {
163-
$this->checkMode &= ~Constraint::CHECK_MODE_APPLY_DEFAULTS;
164-
}
165-
}
166152
}

src/JsonSchema/Validator.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,4 @@ public function coerce(&$value, $schema = null, JsonPointer $path = null, $i = n
5252

5353
$this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
5454
}
55-
56-
/**
57-
* Does everything that coerce does, but will also set values to their default, if the value is not
58-
* set and a default is available in the schema. Note that the first argumen is passwd by
59-
* reference, so you must pass in a variable.
60-
*
61-
* {@inheritDoc}
62-
*/
63-
public function coerceDefault(&$value, $schema = null, JsonPointer $path = null, $i = null)
64-
{
65-
$this->factory->setApplyDefaults(true);
66-
$this->coerce($value, $schema, $path, $i);
67-
}
6855
}

tests/Constraints/DefaultPropertiesTest.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ public function testValidCases($input, $schema, $expectOutput = null)
102102
$inputDecoded = $input;
103103
}
104104

105-
$validator = new Validator();
106-
$validator->coerceDefault($inputDecoded, json_decode($schema));
105+
$checkMode = Constraint::CHECK_MODE_APPLY_DEFAULTS;
106+
$validator = new Validator(new Factory(null, null, $checkMode));
107+
$validator->coerce($inputDecoded, json_decode($schema));
107108

108109
$this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true));
109110

@@ -120,13 +121,4 @@ public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null)
120121
$input = json_decode($input, true);
121122
self::testValidCases($input, $schema, $expectOutput);
122123
}
123-
124-
public function testDontApplyDefaults()
125-
{
126-
$f = new Factory();
127-
$f->setApplyDefaults(false);
128-
129-
$this->assertEquals(0, $f->getCheckMode() & Constraint::CHECK_MODE_APPLY_DEFAULTS);
130-
}
131-
132124
}

0 commit comments

Comments
 (0)