AbstractFfi   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCData() 0 3 1
A __construct() 0 3 1
A setCData() 0 3 1
A getFfi() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chipmunk;
6
7
abstract class AbstractFfi
8
{
9
    private \FFI $ffi;
10
11
    /**
12
     * Represents each class CData. For example, in class Space it represents a cpSpace struct.
13
     */
14
    private \FFI\CData $cData;
15
16
    public function __construct()
17
    {
18
        $this->ffi = Environment::getFfi();
19
    }
20
21
    public function getFfi(): \FFI
22
    {
23
        return $this->ffi;
24
    }
25
26
    /**
27
     * Should be used internally by the wrapper. It allows for example, to receive
28
     * a Vector class from the Space class and get the Vector's CData to set the
29
     * Space's gravity.
30
     */
31
    public function getCData(): \FFI\CData
32
    {
33
        return $this->cData;
34
    }
35
36
    /**
37
     * Should be called at every class constructor to have the required CData to
38
     * work with the FFI.
39
     */
40
    protected function setCData(\FFI\CData $cData): void
41
    {
42
        $this->cData = $cData;
43
    }
44
}
45