/
Constraint.php
60 lines (51 loc) 路 1.27 KB
/
Constraint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace SMW\Constraint;
/**
* @license GNU GPL v2+
* @since 3.1
*
* @author mwjames
*/
interface Constraint {
/**
* Schema types
*/
const CLASS_CONSTRAINT_SCHEMA = 'CLASS_CONSTRAINT_SCHEMA';
const PROPERTY_CONSTRAINT_SCHEMA = 'PROPERTY_CONSTRAINT_SCHEMA';
/**
* The constraint check happens instantaneous on a GET request (aka. online)
* and should be used for "light" checks that doesn't involve the `QueryEngine`
* or a rule resolver given the potential computational requirements that
* are required to run checks on each individual value.
*/
const TYPE_INSTANT = 'type/instant';
/**
* The constraint check happens after a GET request using the job queue.
*/
const TYPE_DEFERRED = 'type/deferred';
/**
* Returns true when a violation during the check occurred.
*
* @since 3.1
*
* @return boolean
*/
public function hasViolation();
/**
* @since 3.1
*
* @return string
*/
public function getType();
/**
* Checks a constraint against a single value. Any error that occurred during
* the processing should be attached to an individual value using the
* `ConstraintError` class.
*
* @since 3.1
*
* @param array $constraint
* @param mixed $value
*/
public function checkConstraint( array $constraint, $value );
}