RawInt32::getCTypeName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\PhpInternals\Types\C;
15
16
use FFI\CInteger;
17
use PhpProfiler\Lib\PhpInternals\CastedCData;
18
use PhpProfiler\Lib\Process\Pointer\Dereferencable;
19
use PhpProfiler\Lib\Process\Pointer\Pointer;
20
21
final class RawInt32 implements Dereferencable
22
{
23
    public int $value;
24
25
    /** @param CastedCData<CInteger> $casted_cdata */
26
    public function __construct(
27
        private CastedCData $casted_cdata,
28
    ) {
29
        $this->value = $this->casted_cdata->casted->cdata;
30
    }
31
32
    public static function getCTypeName(): string
33
    {
34
        return 'int32_t';
35
    }
36
37
    public static function fromCastedCData(
38
        CastedCData $casted_cdata,
39
        Pointer $pointer
40
    ): static {
41
        /** @var CastedCData<CInteger> $casted_cdata */
42
        return new self($casted_cdata);
43
    }
44
}
45