AdhocQueryValidator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A instance() 0 6 2
A get() 0 3 1
A validate() 0 9 3
1
<?php
2
3
namespace Jabe\Impl;
4
5
use Jabe\BadUserRequestException;
6
use Jabe\Impl\Context\Context;
7
8
class AdhocQueryValidator implements ValidatorInterface
9
{
10
11
    private static $INSTANCE;
12
13
    public static function instance(): ValidatorInterface
14
    {
15
        if (self::$INSTANCE === null) {
16
            self::$INSTANCE = new AdhocQueryValidator();
17
        }
18
        return self::$INSTANCE;
19
    }
20
21
    public function validate($query)
22
    {
23
        if (
24
            !Context::getProcessEngineConfiguration()->isEnableExpressionsInAdhocQueries() &&
0 ignored issues
show
Bug introduced by
The method isEnableExpressionsInAdhocQueries() does not exist on Jabe\Impl\Cfg\ProcessEngineConfigurationImpl. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
            !Context::getProcessEngineConfiguration()->/** @scrutinizer ignore-call */ isEnableExpressionsInAdhocQueries() &&

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
            !empty($query->getExpressions())
26
        ) {
27
                throw new BadUserRequestException(
28
                    "Expressions are forbidden in adhoc queries. This behavior can be toggled"
29
                    . " in the process engine configuration"
30
                );
31
        }
32
    }
33
34
    public static function get(): ValidatorInterface
35
    {
36
        return self::instance();
37
    }
38
}
39