Code Duplication    Length = 28-33 lines in 2 locations

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

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

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

@@ 183-210 (lines=28) @@
180
     *
181
     * @return string
182
     */
183
    protected function varToString($var)
184
    {
185
        if (is_object($var)) {
186
            return sprintf('Object(%s)', get_class($var));
187
        }
188
        if (is_array($var)) {
189
            $a = [];
190
            foreach ($var as $k => $v) {
191
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
192
            }
193
194
            return sprintf('Array(%s)', implode(', ', $a));
195
        }
196
        if (is_resource($var)) {
197
            return sprintf('Resource(%s)', get_resource_type($var));
198
        }
199
        if (null === $var) {
200
            return 'null';
201
        }
202
        if (false === $var) {
203
            return 'false';
204
        }
205
        if (true === $var) {
206
            return 'true';
207
        }
208
209
        return (string)$var;
210
    }
211
212
    /**
213
     * Handles an exception by trying to convert it to a Response.