GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

QJUtils   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 15
lcom 0
cbo 1
dl 0
loc 87
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B dbQuote() 0 33 7
B recursiveQuote() 0 24 7
A ajaxResponse() 0 7 1
1
<?php
2
3
namespace Symbiote\QueuedJobs;
4
5
use SilverStripe\Core\Convert;
6
use SilverStripe\ORM\DB;
7
8
/**
9
 * A set of utility functions used by the queued jobs module
10
 *
11
 * @license http://silverstripe.org/bsd-license
12
 * @author Marcus Nyeholt <[email protected]>
13
 */
14
class QJUtils
15
{
16
    /**
17
     * Quote up a filter of the form
18
     *
19
     * array ("ParentID =" => 1)
20
     *
21
     * @param array $filter
22
     * @param string $join
23
     * @return string
24
     */
25
    public function dbQuote($filter = array(), $join = " AND ")
26
    {
27
        $quoteChar = defined(DB::class . '::USE_ANSI_SQL') && DB::USE_ANSI_SQL  ? '"' : '';
28
29
        $string = '';
30
        $sep = '';
31
32
        foreach ($filter as $field => $value) {
33
            // first break the field up into its two components
34
            $operator = '';
35
            if (is_string($field)) {
36
                list($field, $operator) = explode(' ', trim($field));
37
            }
38
39
            $value = $this->recursiveQuote($value);
40
41
            if (strpos($field, '.')) {
42
                list($tb, $fl) = explode('.', $field);
43
                $string .= $sep . $quoteChar . $tb . $quoteChar . '.' . $quoteChar . $fl . $quoteChar
44
                    . " $operator " . $value;
45
            } else {
46
                if (is_numeric($field)) {
47
                    $string .= $sep . $value;
48
                } else {
49
                    $string .= $sep . $quoteChar . $field . $quoteChar . " $operator " . $value;
50
                }
51
            }
52
53
            $sep = $join;
54
        }
55
56
        return $string;
57
    }
58
59
    /**
60
     * @param mixed $val
61
     * @return string
62
     */
63
    protected function recursiveQuote($val)
64
    {
65
        if (is_array($val)) {
66
            $return = array();
67
            foreach ($val as $v) {
68
                $return[] = $this->recursiveQuote($v);
69
            }
70
71
            return '(' . implode(',', $return) . ')';
72
        }
73
        if (is_null($val)) {
74
            $val = 'NULL';
75
        } elseif (is_int($val)) {
76
            $val = (int) $val;
77
        } elseif (is_double($val)) {
78
            $val = (double) $val;
79
        } elseif (is_float($val)) {
80
            $val = (float) $val;
81
        } else {
82
            $val = "'" . Convert::raw2sql($val) . "'";
83
        }
84
85
        return $val;
86
    }
87
88
    /**
89
     * @param string $message
90
     * @param string $status
91
     * @return string
92
     */
93
    public function ajaxResponse($message, $status)
94
    {
95
        return json_encode(array(
96
            'message' => $message,
97
            'status' => $status,
98
        ));
99
    }
100
}
101