CBytesBuffer::write()   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 2
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-fuse 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 Fuse\Libc\String;
15
16
use FFI\CData;
17
use TypedCData\TypedCDataInterface;
0 ignored issues
show
Bug introduced by
The type TypedCData\TypedCDataInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
final class CBytesBuffer implements TypedCDataInterface
20
{
21
    private CData $cdata;
22
23
    public function __construct(CData $cdata)
24
    {
25
        $this->cdata = $cdata;
26
    }
27
28
    /** @return static */
29
    public static function fromCData(CData $cdata): self
30
    {
31
        return new self($cdata);
32
    }
33
34
    public static function getCTypeName(): string
35
    {
36
        return 'char *';
37
    }
38
39
    public function write(string $content, int $size): void
40
    {
41
        \FFI::memcpy($this->cdata, $content, $size);
42
    }
43
44
    public function toCData(CData $cdata): CData
45
    {
46
        return $cdata;
47
    }
48
49
    public static function newCData(): CData
50
    {
51
        /** @var CData */
52
        return \FFI::new('char[1]');
53
    }
54
}
55