/var/www/hkosl.com/demo_google/application/vendor/illuminate/database/Query/JsonExpression.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
61
62
63
64
65
66
67
68
69
70
<?php

namespace Illuminate\Database\Query;

use 
InvalidArgumentException;

class 
JsonExpression extends Expression
{
    
/**
     * The value of the expression.
     *
     * @var mixed
     */
    
protected $value;

    
/**
     * Create a new raw query expression.
     *
     * @param  mixed  $value
     * @return void
     */
    
public function __construct($value)
    {
        
$this->value $this->getJsonBindingParameter($value);
    }

    
/**
     * Translate the given value into the appropriate JSON binding parameter.
     *
     * @param  mixed  $value
     * @return string
     */
    
protected function getJsonBindingParameter($value)
    {
        switch (
$type gettype($value)) {
            case 
'boolean':
                return 
$value 'true' 'false';
            case 
'integer':
            case 
'double':
                return 
$value;
            case 
'string':
                return 
'?';
            case 
'object':
            case 
'array':
                return 
'?';
        }

        throw new 
InvalidArgumentException('JSON value is of illegal type: '.$type);
    }

    
/**
     * Get the value of the expression.
     *
     * @return mixed
     */
    
public function getValue()
    {
        return 
$this->value;
    }

    
/**
     * Get the value of the expression.
     *
     * @return string
     */
    
public function __toString()
    {
        return (string) 
$this->getValue();
    }
}