SetByMethod::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Gson\Internal\AccessorStrategy;
10
11
use Tebru\Gson\Internal\SetterStrategy;
12
13
/**
14
 * Class SetByMethod
15
 *
16
 * This class contains public properties to improve performance.
17
 *
18
 * @author Nate Brunette <[email protected]>
19
 */
20
final class SetByMethod implements SetterStrategy
21
{
22
    /**
23
     * @var string
24
     */
25
    public $methodName;
26
27
    /**
28
     * Constructor
29
     *
30
     * @param string $methodName
31
     */
32 2
    public function __construct(string $methodName)
33
    {
34 2
        $this->methodName = $methodName;
35 2
    }
36
37
    /**
38
     * Set value to object by method name
39
     *
40
     * @param object $object
41
     * @param mixed $value
42
     * @return void
43
     */
44 2
    public function set($object, $value): void
45
    {
46 2
        $object->{$this->methodName}($value);
47 1
    }
48
}
49