StatVfs::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 12
c 1
b 0
f 1
nc 1
nop 12
dl 0
loc 26
rs 9.8666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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\Sys\StatVfs;
15
16
use FFI\CData;
17
use Fuse\FFI\TypedCDataDefaultImplementationTrait;
18
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...
19
20
/**
21
 * struct statvfs
22
 * {
23
 *     unsigned long int f_bsize;
24
 *     unsigned long int f_frsize;
25
 *     fsblkcnt64_t f_blocks;
26
 *     fsblkcnt64_t f_bfree;
27
 *     fsblkcnt64_t f_bavail;
28
 *     fsblkcnt64_t f_files;
29
 *     fsblkcnt64_t f_ffree;
30
 *     fsblkcnt64_t f_favail;
31
 *     unsigned long int f_fsid;
32
 *     unsigned long int f_flag;
33
 *     unsigned long int f_namemax;
34
 *     int __f_spare[6];
35
 * };
36
 */
37
final class StatVfs implements TypedCDataInterface
38
{
39
    use TypedCDataDefaultImplementationTrait;
40
41
    public int $f_bsize;
42
    public int $f_frsize;
43
    public int $f_blocks;
44
    public int $f_bfree;
45
    public int $f_bavail;
46
    public int $f_files;
47
    public int $f_ffree;
48
    public int $f_favail;
49
    public int $f_fsid;
50
    public int $f_flag;
51
    public int $f_namemax;
52
    // phpcs:ignore PSR2.Classes.PropertyDeclaration
53
    public ?CData $__f_spare;
54
55
    public function __construct(
56
        int $f_bsize = 0,
57
        int $f_frsize = 0,
58
        int $f_blocks = 0,
59
        int $f_bfree = 0,
60
        int $f_bavail = 0,
61
        int $f_files = 0,
62
        int $f_ffree = 0,
63
        int $f_favail = 0,
64
        int $f_fsid = 0,
65
        int $f_flag = 0,
66
        int $f_namemax = 0,
67
        ?CData $__f_spare = null
68
    ) {
69
        $this->f_bsize = $f_bsize;
70
        $this->f_frsize = $f_frsize;
71
        $this->f_blocks = $f_blocks;
72
        $this->f_bfree = $f_bfree;
73
        $this->f_bavail = $f_bavail;
74
        $this->f_files = $f_files;
75
        $this->f_ffree = $f_ffree;
76
        $this->f_favail = $f_favail;
77
        $this->f_fsid = $f_fsid;
78
        $this->f_flag = $f_flag;
79
        $this->f_namemax = $f_namemax;
80
        $this->__f_spare = $__f_spare;
81
    }
82
83
    public static function getCTypeName(): string
84
    {
85
        return 'struct statvfs *';
86
    }
87
}
88