Stat::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 15
c 1
b 0
f 1
nc 1
nop 15
dl 0
loc 32
rs 9.7666

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\Stat;
15
16
use FFI\CData;
17
use Fuse\FFI\TypedCDataDefaultImplementationTrait;
18
use Fuse\Libc\Time\TimeSpec;
19
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...
20
21
/**
22
 * struct stat
23
 * {
24
 *     dev_t st_dev;
25
 *     ino_t st_ino;
26
 *     nlink_t st_nlink;
27
 *     mode_t st_mode;
28
 *     uid_t st_uid;
29
 *     gid_t st_gid;
30
 *     int __pad0;
31
 *     dev_t st_rdev;
32
 *     off_t st_size;
33
 *     blksize_t st_blksize;
34
 *     blkcnt_t st_blocks;
35
 *     struct timespec st_atim;
36
 *     struct timespec st_mtim;
37
 *     struct timespec st_ctim;
38
 *     long int reserved[3];
39
 * };
40
 */
41
final class Stat implements TypedCDataInterface
42
{
43
    use TypedCDataDefaultImplementationTrait;
44
45
    public const S_IFDIR = 0040000;
46
    public const S_IFREG = 0100000;
47
48
    public static function getCTypeName(): string
49
    {
50
        return 'struct stat';
51
    }
52
53
    public int $st_dev;
54
    public int $st_ino;
55
    public int $st_nlink;
56
    public int $st_mode;
57
    public int $st_uid;
58
    public int $st_gid;
59
    // phpcs:ignore PSR2.Classes.PropertyDeclaration
60
    public int $__pad0;
61
    public int $st_rdev;
62
    public int $st_size;
63
    public int $st_blksize;
64
    public int $st_blocks;
65
    public TimeSpec $st_atim;
66
    public TimeSpec $st_mtim;
67
    public TimeSpec $st_ctim;
68
    public ?CData $reserved;
69
70
    public function __construct(
71
        int $st_dev = 0,
72
        int $st_ino = 0,
73
        int $st_nlink = 0,
74
        int $st_mode = 0,
75
        int $st_uid = 0,
76
        int $st_gid = 0,
77
        int $__pad0 = 0,
78
        int $st_rdev = 0,
79
        int $st_size = 0,
80
        int $st_blksize = 0,
81
        int $st_blocks = 0,
82
        ?TimeSpec $st_atim = null,
83
        ?TimeSpec $st_mtim = null,
84
        ?TimeSpec $st_ctim = null,
85
        ?CData $reserved = null
86
    ) {
87
        $this->st_dev = $st_dev;
88
        $this->st_ino = $st_ino;
89
        $this->st_nlink = $st_nlink;
90
        $this->st_mode = $st_mode;
91
        $this->st_uid = $st_uid;
92
        $this->st_gid = $st_gid;
93
        $this->__pad0 = $__pad0;
94
        $this->st_rdev = $st_rdev;
95
        $this->st_size = $st_size;
96
        $this->st_blksize = $st_blksize;
97
        $this->st_blocks = $st_blocks;
98
        $this->st_atim = $st_atim ?? new TimeSpec();
99
        $this->st_mtim = $st_mtim ?? new TimeSpec();
100
        $this->st_ctim = $st_ctim ?? new TimeSpec();
101
        $this->reserved = $reserved;
102
    }
103
}
104