AbstractResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toCamelCase() 0 3 1
A fromJson() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Package: PHP Bitaps API
7
 *
8
 * (c) Eldar Gazaliev <[email protected]>
9
 *
10
 *  Link: <https://github.com/MyZik>
11
 *
12
 * For the full copyright and license information, please view the LICENSE file
13
 * that was distributed with this source code.
14
 */
15
16
namespace Bitaps\WalletAPI\Response;
17
18
use JMS\Serializer\SerializerBuilder;
19
20
abstract class AbstractResponse
21
{
22
    /**
23
     * @param string $json
24
     *
25
     * @return mixed
26
     */
27
    public static function fromJson(string $json)
28
    {
29
        $object = new static();
30
31
        $serializer = SerializerBuilder::create()->build();
32
33
        return $serializer->deserialize($json, get_class($object), 'json');
34
    }
35
36
    /**
37
     * @param string $string
38
     *
39
     * @return string|string[]
40
     */
41
    protected static function toCamelCase(string $string)
42
    {
43
        return str_replace(" ", "", ucwords(str_replace("_", " ", $string)));
44
    }
45
}
46