summaryrefslogtreecommitdiffstats
path: root/vendor/gipfl/socket/src/UnixSocketPeer.php
blob: 409487baadd7117e59a4cd2fc85455e8449de713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php

namespace gipfl\Socket;

use gipfl\Json\JsonSerialization;

class UnixSocketPeer implements JsonSerialization
{
    /** @var int */
    protected $pid;

    /** @var int */
    protected $uid;

    /** @var int */
    protected $gid;

    /** @var string */
    protected $username;

    /** @var ?string */
    protected $fullName;

    /** @var string */
    protected $groupName;

    public function __construct($pid, $uid, $gid, $username, $fullName, $groupName)
    {
        $this->pid = $pid;
        $this->uid = $uid;
        $this->gid = $gid;
        $this->username = $username;
        $this->fullName = $fullName;
        $this->groupName = $groupName;
    }

    /**
     * @return int
     */
    public function getPid()
    {
        return $this->pid;
    }

    /**
     * @return int
     */
    public function getUid()
    {
        return $this->uid;
    }

    /**
     * @return int
     */
    public function getGid()
    {
        return $this->gid;
    }

    /**
     * @return string
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * @return string|null
     */
    public function getFullName()
    {
        return $this->fullName;
    }

    /**
     * @return string
     */
    public function getGroupName()
    {
        return $this->groupName;
    }

    public static function fromSerialization($any)
    {
        return new static($any->pid, $any->uid, $any->gid, $any->username, $any->fullName, $any->groupName);
    }

    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        return (object) [
            'pid' => $this->pid,
            'uid' => $this->uid,
            'gid' => $this->gid,
            'username'  => $this->username,
            'fullName'  => $this->fullName,
            'groupName' => $this->groupName,
        ];
    }
}