Code Duplication    Length = 28-33 lines in 2 locations

src/Bankiru/Api/Rpc/Routing/Exception/FileLoaderLoadException.php 1 location

@@ 58-90 (lines=33) @@
55
        parent::__construct($message, $code, $previous);
56
    }
57
58
    protected function varToString($var)
59
    {
60
        if (is_object($var)) {
61
            return sprintf('Object(%s)', get_class($var));
62
        }
63
64
        if (is_array($var)) {
65
            $a = [];
66
            foreach ($var as $k => $v) {
67
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
68
            }
69
70
            return sprintf('Array(%s)', implode(', ', $a));
71
        }
72
73
        if (is_resource($var)) {
74
            return sprintf('Resource(%s)', get_resource_type($var));
75
        }
76
77
        if (null === $var) {
78
            return 'null';
79
        }
80
81
        if (false === $var) {
82
            return 'false';
83
        }
84
85
        if (true === $var) {
86
            return 'true';
87
        }
88
89
        return (string)$var;
90
    }
91
}
92

src/Bankiru/Api/Rpc/Controller/RpcController.php 1 location

@@ 196-223 (lines=28) @@
193
     *
194
     * @return string
195
     */
196
    protected function varToString($var)
197
    {
198
        if (is_object($var)) {
199
            return sprintf('Object(%s)', get_class($var));
200
        }
201
        if (is_array($var)) {
202
            $a = [];
203
            foreach ($var as $k => $v) {
204
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
205
            }
206
207
            return sprintf('Array(%s)', implode(', ', $a));
208
        }
209
        if (is_resource($var)) {
210
            return sprintf('Resource(%s)', get_resource_type($var));
211
        }
212
        if (null === $var) {
213
            return 'null';
214
        }
215
        if (false === $var) {
216
            return 'false';
217
        }
218
        if (true === $var) {
219
            return 'true';
220
        }
221
222
        return (string)$var;
223
    }
224
225
    /**
226
     * Handles an exception by trying to convert it to a Response.