Completed
Push — master ( bd87f9...9971b9 )
by Richard
06:03
created

Property   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 46
ccs 2
cts 2
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
name() 0 1 ?
A parse_as() 0 3 1
fetch_arguments() 0 1 ?
arguments_are_valid() 0 1 ?
compile() 0 1 ?
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 * 
5
 * Copyright (c) 2016, 2015 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\Variables;
12
13
use Lechimp\Dicto\Definition\ArgumentParser;
14
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
15
16
/**
17
 * Defines the property of some variable.
18
 */
19
abstract class Property {
20
    /**
21
     * Name of the property.
22
     *
23
     * @return  string
24
     */
25
    abstract public function name();
26
27
    /**
28
     * How to match property during parsing.
29
     *
30
     * Defaults to "with $name"
31
     *
32
     * @return string
33
     */
34 25
    public function parse_as() {
35 25
        return "with ".$this->name();
36
    }
37
38
    /**
39
     * Fetch arguments for the Property from a stream of tokens during parsing.
40
     *
41
     * @param   ArgumentParser  $parser
42
     * @return  array
43
     */
44
    abstract public function fetch_arguments(ArgumentParser $parser);
45
46
    /**
47
     * Check if the given arguments are valid for the property.
48
     *
49
     * @param   array   $arguments
50
     * @return  bool 
51
     */
52
    abstract public function arguments_are_valid(array &$arguments);
53
54
    /**
55
     * Compile the property to an SQL expression.
56
     *
57
     * @param   array               $argument
0 ignored issues
show
Documentation introduced by
There is no parameter named $argument. Did you maybe mean $arguments?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
58
     * @param   ExpressionBuilder   $builder
59
     * @param   string              $table_name
60
     * @param   bool                $negate
61
     * @return  string|CompositeExpression
62
     */
63
    abstract public function compile(array &$arguments, ExpressionBuilder $builder, $table_name, $negate = false);
64
}
65