Completed
Push — master ( 31785d...5192f1 )
by Richard
06:45
created

Schema::to_violation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
nc 1
cc 1
eloc 6
nop 2
crap 1
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 *
5
 * Copyright (c) 2016 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received
8
 * a copy of the license along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Rules;
12
13
use Lechimp\Dicto\Analysis\Violation;
14
use Lechimp\Dicto\Definition\ArgumentParser;
15
use Lechimp\Dicto\Indexer\ListenerRegistry;
16
use Lechimp\Dicto\Variables\Variable;
17
use Lechimp\Dicto\Analysis\Index;
18
use Lechimp\Dicto\Graph\Query;
19
20
/**
21
 * This is what every rule needs to define.
22
 */
23
abstract class Schema {
24
    /**
25
     * Get the name of the schema.
26
     *
27
     * @return  string
28
     */
29
    abstract public function name(); 
30
31
    /**
32
     * Fetch arguments for the Schema from a stream of tokens during parsing.
33
     *
34
     * @param   ArgumentParser  $parser
35
     * @return  array
36
     */
37
    abstract public function fetch_arguments(ArgumentParser $parser);
38
39
    /**
40
     * Check if the given arguments are valid for the rule schema.
41
     *
42
     * @param   array   $arguments
43
     * @return  bool 
44
     */
45
    abstract public function arguments_are_valid(array &$arguments);
46
47
    /**
48
     * Get a pretty printed version of the rules.
49
     *
50
     * @param   Rule    $rule
51
     * @return  string
52
     */
53
    abstract public function pprint(Rule $rule);
54
55
    /**
56
     * Compile a given rule into an sql statement using a query interface.
57
     *
58
     * @param   Index       $index
59
     * @param   Rule        $rule
60
     * @return  Query
61
     */
62
    abstract public function compile(Index $index, Rule $rule);
63
64
    /**
65
     * Register listeners to the indexer that are required to detect information
66
     * for the rule.
67
     *
68
     * @param   ListenerRegistry $registry
69
     * @return  null
70
     */
71
    abstract public function register_listeners(ListenerRegistry $registry);
72
}
73