Completed
Push — master ( 8bbda0...ede634 )
by ARCANEDEV
8s
created

AttachedObject   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
ccs 0
cts 9
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A replaceWith() 0 13 3
1
<?php namespace Arcanedev\Stripe;
2
3
use Arcanedev\Stripe\Contracts\AttachedObjectInterface;
4
5
/**
6
 * Class     AttachedObject
7
 *
8
 * @package  Arcanedev\Stripe
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class AttachedObject extends StripeObject implements AttachedObjectInterface
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * @var bool
19
     */
20
    protected $checkUnsavedAttributes = false;
21
22
    /* ------------------------------------------------------------------------------------------------
23
     |  Main Functions
24
     | ------------------------------------------------------------------------------------------------
25
     */
26
    /**
27
     * Updates this object.
28
     *
29
     * @param array $properties - A mapping of properties to update on this object.
30
     */
31
    public function replaceWith($properties)
32
    {
33
        $removed = array_diff(array_keys($this->values), array_keys($properties));
34
35
        // Don't unset, but rather set to null so we send up '' for deletion.
36
        foreach ($removed as $k) {
37
            $this->$k = null;
38
        }
39
40
        foreach ($properties as $k => $v) {
41
            $this->$k = $v;
42
        }
43
    }
44
}
45