Completed
Push — master ( ba6a5c...060d7c )
by ARCANEDEV
12s
created

AttachedObject::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php namespace Arcanedev\Stripe;
2
3
use Arcanedev\Stripe\Contracts\AttachedObject as AttachedObjectContract;
4
5
/**
6
 * Class     AttachedObject
7
 *
8
 * @package  Arcanedev\Stripe
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class AttachedObject extends StripeObject implements AttachedObjectContract
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /** @var bool */
19
    protected $checkUnsavedAttributes = false;
20
21
    /* -----------------------------------------------------------------
22
     |  Main Functions
23
     | -----------------------------------------------------------------
24
     */
25
26
    /**
27
     * Updates this object.
28
     *
29
     * @param  array  $properties  -  A mapping of properties to update on this object.
30
     */
31 15
    public function replaceWith($properties)
32
    {
33 15
        $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 15
        foreach ($removed as $k) {
37 3
            $this->$k = null;
38 5
        }
39
40 15
        foreach ($properties as $k => $v) {
41 15
            $this->$k = $v;
42 5
        }
43 15
    }
44
45
    /**
46
     * Counts the number of elements.
47
     *
48
     * @return int
49
     */
50 12
    public function count()
51
    {
52 12
        return count($this->values);
53
    }
54
}
55