Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.75% covered (success)
93.75%
30 / 32
94.12% covered (success)
94.12%
16 / 17
CRAP
0.00% covered (danger)
0.00%
0 / 1
Maxfield
93.75% covered (success)
93.75%
30 / 32
94.12% covered (success)
94.12%
16 / 17
19.09
0.00% covered (danger)
0.00%
0 / 1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getOwner
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setOwner
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getJsonData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setJsonData
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getUserData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUserData
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getPlanResults
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPlanResults
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setUserKeysWithUser
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPath
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setCurrentPointWithUser
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 setFarmDoneWithUser
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 initUserData
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace App\Entity;
6
7use stdClass;
8use App\Repository\MaxfieldRepository;
9use App\Type\AgentKeyInfo;
10use Doctrine\DBAL\Types\Types;
11use Doctrine\ORM\Mapping\Column;
12use Doctrine\ORM\Mapping\Entity;
13use Doctrine\ORM\Mapping\GeneratedValue;
14use Doctrine\ORM\Mapping\Id;
15use Doctrine\ORM\Mapping\JoinColumn;
16use Doctrine\ORM\Mapping\ManyToOne;
17use Elkuku\MaxfieldParser\Type\Waypoint;
18
19#[Entity(repositoryClass: MaxfieldRepository::class)]
20class Maxfield
21{
22    #[Column, Id, GeneratedValue(strategy: 'SEQUENCE')]
23    private ?int $id = null;
24
25    #[Column(type: Types::STRING, length: 150)]
26    private ?string $name = null;
27
28    #[Column(length: 255, nullable: true)]
29    private ?string $path = null;
30
31    #[ManyToOne(targetEntity: User::class, inversedBy: 'maxfields')]
32    #[JoinColumn(nullable: false)]
33    private ?User $owner = null;
34
35    /**
36     * @var array<string, array<Waypoint|stdClass>>|null
37     */
38    #[Column(type: Types::JSON, nullable: true)]
39    private array|null $jsonData = null;
40
41    /**
42     * @var array<int, array{keys?: array<AgentKeyInfo>, current_point?: string, farm_done?: array<int>}>|null
43     */
44    #[Column(type: Types::JSON, nullable: true)]
45    private ?array $userData = null;
46
47    #[Column(type: Types::JSON, nullable: true)]
48    private ?array $planResults = null;
49
50    public function getId(): ?int
51    {
52        return $this->id;
53    }
54
55    public function getName(): ?string
56    {
57        return $this->name;
58    }
59
60    public function setName(string $name): self
61    {
62        $this->name = $name;
63
64        return $this;
65    }
66
67    public function getOwner(): ?User
68    {
69        return $this->owner;
70    }
71
72    public function setOwner(?User $owner): self
73    {
74        $this->owner = $owner;
75
76        return $this;
77    }
78
79    /**
80     * @return array<string, array<Waypoint|stdClass>>|null
81     */
82    public function getJsonData(): ?array
83    {
84        return $this->jsonData;
85    }
86
87    /**
88     * @param array<string, array<Waypoint|stdClass>> $jsonData
89     */
90    public function setJsonData(array $jsonData): self
91    {
92        $this->jsonData = $jsonData;
93
94        return $this;
95    }
96
97    /**
98     * @return array<int, array{keys?: array<AgentKeyInfo>, current_point?: string, farm_done?: array<int>}>|null
99     */
100    public function getUserData(): ?array
101    {
102        return $this->userData;
103    }
104
105    /**
106     * @param array<int, array{keys?: array<AgentKeyInfo>, current_point?: string, farm_done?: array<int>}> $userData
107     */
108    public function setUserData(array $userData): self
109    {
110        $this->userData = $userData;
111
112        return $this;
113    }
114
115    public function getPlanResults(): ?array
116    {
117        return $this->planResults;
118    }
119
120    public function setPlanResults(?array $planResults): static
121    {
122        $this->planResults = $planResults;
123
124        return $this;
125    }
126
127    /**
128     * @param AgentKeyInfo[] $userKeys
129     */
130    public function setUserKeysWithUser(array $userKeys, int $user): self
131    {
132        $this->initUserData($user);
133        $this->userData[$user]['keys'] = $userKeys;
134
135        return $this;
136    }
137
138    public function getPath(): ?string
139    {
140        return $this->path;
141    }
142
143    public function setPath(?string $path): self
144    {
145        $this->path = $path;
146
147        return $this;
148    }
149
150    public function setCurrentPointWithUser(string $currentPoint, int $user): self
151    {
152        $this->initUserData($user);
153        $this->userData[$user]['current_point'] = $currentPoint;
154
155        return $this;
156    }
157
158    /**
159     * @param array<int> $farmDone
160     */
161    public function setFarmDoneWithUser(array $farmDone, int $user): self
162    {
163        $this->initUserData($user);
164        $this->userData[$user]['farm_done'] = $farmDone;
165
166        return $this;
167    }
168
169    private function initUserData(int $user): void
170    {
171        if (!$this->userData) {
172            $this->userData = [];
173        }
174
175        if (!isset($this->userData[$user])) {
176            $this->userData[$user] = [];
177        }
178    }
179}