Lines
100.00%
86 / 86
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| AgentStat | 100.00% | 86 / 86 | 100.00% | 2 / 2 | 2 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 44 / 44 | 100.00% | 1 / 1 | 1 | |||||
| getStats | 100.00% | 42 / 42 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace App\Entity; | |
| 6 | ||
| 7 | use App\Dto\AgentStatInput; | |
| 8 | use App\Repository\AgentStatRepository; | |
| 9 | use Doctrine\DBAL\Types\Types; | |
| 10 | use Doctrine\ORM\Mapping\Column; | |
| 11 | use Doctrine\ORM\Mapping\Entity; | |
| 12 | use Doctrine\ORM\Mapping\GeneratedValue; | |
| 13 | use Doctrine\ORM\Mapping\Id; | |
| 14 | use Doctrine\ORM\Mapping\JoinColumn; | |
| 15 | use Doctrine\ORM\Mapping\ManyToOne; | |
| 16 | use Doctrine\ORM\Mapping\UniqueConstraint; | |
| 17 | ||
| 18 | /** | |
| 19 | * Ingress all-time agent stats, with the columns of 4e-website's agent_stat table. | |
| 20 | * 4e-website links a row to its Agent; here it belongs to the User who imported it. | |
| 21 | */ | |
| 22 | #[Entity(repositoryClass: AgentStatRepository::class)] | |
| 23 | #[UniqueConstraint(name: 'agent_stat_owner_datetime', columns: ['owner_id', 'datetime'])] | |
| 24 | class AgentStat | |
| 25 | { | |
| 26 | #[Column, Id, GeneratedValue] | |
| 27 | public ?int $id = null { | |
| 28 | get { | |
| 29 | return $this->id; | |
| 30 | } | |
| 31 | } | |
| 32 | ||
| 33 | #[Column(type: Types::DATETIME_IMMUTABLE)] | |
| 34 | public private(set) \DateTimeImmutable $datetime; | |
| 35 | ||
| 36 | #[Column(type: Types::DATETIME_IMMUTABLE)] | |
| 37 | public private(set) \DateTimeImmutable $createdAt; | |
| 38 | ||
| 39 | #[Column(length: 150)] | |
| 40 | public private(set) string $nickname; | |
| 41 | ||
| 42 | #[Column(length: 50)] | |
| 43 | public private(set) string $faction; | |
| 44 | ||
| 45 | #[Column] | |
| 46 | public private(set) int $ap; | |
| 47 | ||
| 48 | #[Column(nullable: true)] | |
| 49 | public private(set) ?int $level; | |
| 50 | ||
| 51 | #[Column(nullable: true)] | |
| 52 | public private(set) ?int $explorer; | |
| 53 | ||
| 54 | #[Column(nullable: true)] | |
| 55 | public private(set) ?int $recon; | |
| 56 | ||
| 57 | #[Column(nullable: true)] | |
| 58 | public private(set) ?int $seer; | |
| 59 | ||
| 60 | #[Column(nullable: true)] | |
| 61 | public private(set) ?int $trekker; | |
| 62 | ||
| 63 | #[Column(nullable: true)] | |
| 64 | public private(set) ?int $builder; | |
| 65 | ||
| 66 | #[Column(nullable: true)] | |
| 67 | public private(set) ?int $connector; | |
| 68 | ||
| 69 | #[Column(nullable: true)] | |
| 70 | public private(set) ?int $mindController; | |
| 71 | ||
| 72 | #[Column(nullable: true)] | |
| 73 | public private(set) ?int $illuminator; | |
| 74 | ||
| 75 | #[Column(nullable: true)] | |
| 76 | public private(set) ?int $recharger; | |
| 77 | ||
| 78 | #[Column(nullable: true)] | |
| 79 | public private(set) ?int $liberator; | |
| 80 | ||
| 81 | #[Column(nullable: true)] | |
| 82 | public private(set) ?int $pioneer; | |
| 83 | ||
| 84 | #[Column(nullable: true)] | |
| 85 | public private(set) ?int $engineer; | |
| 86 | ||
| 87 | #[Column(nullable: true)] | |
| 88 | public private(set) ?int $purifier; | |
| 89 | ||
| 90 | #[Column(nullable: true)] | |
| 91 | public private(set) ?int $specops; | |
| 92 | ||
| 93 | #[Column(nullable: true)] | |
| 94 | public private(set) ?int $hacker; | |
| 95 | ||
| 96 | #[Column(nullable: true)] | |
| 97 | public private(set) ?int $translator; | |
| 98 | ||
| 99 | #[Column(nullable: true)] | |
| 100 | public private(set) ?int $sojourner; | |
| 101 | ||
| 102 | #[Column(nullable: true)] | |
| 103 | public private(set) ?int $recruiter; | |
| 104 | ||
| 105 | #[Column(nullable: true)] | |
| 106 | public private(set) ?int $missionday; | |
| 107 | ||
| 108 | #[Column(nullable: true)] | |
| 109 | public private(set) ?int $nl1331Meetups; | |
| 110 | ||
| 111 | #[Column(nullable: true)] | |
| 112 | public private(set) ?int $ifs; | |
| 113 | ||
| 114 | #[Column(nullable: true)] | |
| 115 | public private(set) ?int $currentChallenge; | |
| 116 | ||
| 117 | #[Column(nullable: true)] | |
| 118 | public private(set) ?int $scout; | |
| 119 | ||
| 120 | #[Column(nullable: true)] | |
| 121 | public private(set) ?int $scoutController; | |
| 122 | ||
| 123 | #[Column(nullable: true)] | |
| 124 | public private(set) ?int $longestLink; | |
| 125 | ||
| 126 | #[Column(nullable: true)] | |
| 127 | public private(set) ?int $largestField; | |
| 128 | ||
| 129 | #[Column(nullable: true)] | |
| 130 | public private(set) ?int $recursions; | |
| 131 | ||
| 132 | #[Column(nullable: true)] | |
| 133 | public private(set) ?int $droneFlightDistance; | |
| 134 | ||
| 135 | #[Column(nullable: true)] | |
| 136 | public private(set) ?int $maverick; | |
| 137 | ||
| 138 | #[Column(nullable: true)] | |
| 139 | public private(set) ?int $dronePortalsVisited; | |
| 140 | ||
| 141 | #[Column(nullable: true)] | |
| 142 | public private(set) ?int $droneForcedRecalls; | |
| 143 | ||
| 144 | #[Column(nullable: true)] | |
| 145 | public private(set) ?int $kineticCapsulesCompleted; | |
| 146 | ||
| 147 | #[Column(nullable: true)] | |
| 148 | public private(set) ?int $monthsSubscribed; | |
| 149 | ||
| 150 | #[Column(nullable: true)] | |
| 151 | public private(set) ?int $epoch; | |
| 152 | ||
| 153 | #[Column(nullable: true)] | |
| 154 | public private(set) ?int $portalsDiscovered; | |
| 155 | ||
| 156 | #[Column(nullable: true)] | |
| 157 | public private(set) ?int $dronesReturned; | |
| 158 | ||
| 159 | #[Column(nullable: true)] | |
| 160 | public private(set) ?int $secondSunday; | |
| 161 | ||
| 162 | #[Column(nullable: true)] | |
| 163 | public private(set) ?int $reclaimer; | |
| 164 | ||
| 165 | /** | |
| 166 | * @param AgentStatInput $input validated input | |
| 167 | */ | |
| 168 | public function __construct(#[ManyToOne, JoinColumn(nullable: false, onDelete: 'CASCADE')] | |
| 169 | public private(set) User $owner, AgentStatInput $input) | |
| 170 | { | |
| 171 | $this->datetime = $input->getDateTime(); | |
| 172 | $this->createdAt = new \DateTimeImmutable(); | |
| 173 | $this->nickname = \trim($input->nickname); | |
| 174 | $this->faction = \trim($input->faction); | |
| 175 | $this->ap = $input->ap ?? 0; | |
| 176 | $this->level = $input->level; | |
| 177 | $this->explorer = $input->explorer; | |
| 178 | $this->recon = $input->recon; | |
| 179 | $this->seer = $input->seer; | |
| 180 | $this->trekker = $input->trekker; | |
| 181 | $this->builder = $input->builder; | |
| 182 | $this->connector = $input->connector; | |
| 183 | $this->mindController = $input->mindController; | |
| 184 | $this->illuminator = $input->illuminator; | |
| 185 | $this->recharger = $input->recharger; | |
| 186 | $this->liberator = $input->liberator; | |
| 187 | $this->pioneer = $input->pioneer; | |
| 188 | $this->engineer = $input->engineer; | |
| 189 | $this->purifier = $input->purifier; | |
| 190 | $this->specops = $input->specops; | |
| 191 | $this->hacker = $input->hacker; | |
| 192 | $this->translator = $input->translator; | |
| 193 | $this->sojourner = $input->sojourner; | |
| 194 | $this->recruiter = $input->recruiter; | |
| 195 | $this->missionday = $input->missionday; | |
| 196 | $this->nl1331Meetups = $input->nl1331Meetups; | |
| 197 | $this->ifs = $input->ifs; | |
| 198 | $this->currentChallenge = $input->currentChallenge; | |
| 199 | $this->scout = $input->scout; | |
| 200 | $this->scoutController = $input->scoutController; | |
| 201 | $this->longestLink = $input->longestLink; | |
| 202 | $this->largestField = $input->largestField; | |
| 203 | $this->recursions = $input->recursions; | |
| 204 | $this->droneFlightDistance = $input->droneFlightDistance; | |
| 205 | $this->maverick = $input->maverick; | |
| 206 | $this->dronePortalsVisited = $input->dronePortalsVisited; | |
| 207 | $this->droneForcedRecalls = $input->droneForcedRecalls; | |
| 208 | $this->kineticCapsulesCompleted = $input->kineticCapsulesCompleted; | |
| 209 | $this->monthsSubscribed = $input->monthsSubscribed; | |
| 210 | $this->epoch = $input->epoch; | |
| 211 | $this->portalsDiscovered = $input->portalsDiscovered; | |
| 212 | $this->dronesReturned = $input->dronesReturned; | |
| 213 | $this->secondSunday = $input->secondSunday; | |
| 214 | $this->reclaimer = $input->reclaimer; | |
| 215 | } | |
| 216 | ||
| 217 | /** | |
| 218 | * The stats by agent_stat column name, for display. | |
| 219 | * | |
| 220 | * @return array<string, int|null> | |
| 221 | */ | |
| 222 | public function getStats(): array | |
| 223 | { | |
| 224 | return [ | |
| 225 | 'level' => $this->level, | |
| 226 | 'ap' => $this->ap, | |
| 227 | 'explorer' => $this->explorer, | |
| 228 | 'recon' => $this->recon, | |
| 229 | 'seer' => $this->seer, | |
| 230 | 'trekker' => $this->trekker, | |
| 231 | 'builder' => $this->builder, | |
| 232 | 'connector' => $this->connector, | |
| 233 | 'mind_controller' => $this->mindController, | |
| 234 | 'illuminator' => $this->illuminator, | |
| 235 | 'recharger' => $this->recharger, | |
| 236 | 'liberator' => $this->liberator, | |
| 237 | 'pioneer' => $this->pioneer, | |
| 238 | 'engineer' => $this->engineer, | |
| 239 | 'purifier' => $this->purifier, | |
| 240 | 'specops' => $this->specops, | |
| 241 | 'hacker' => $this->hacker, | |
| 242 | 'translator' => $this->translator, | |
| 243 | 'sojourner' => $this->sojourner, | |
| 244 | 'recruiter' => $this->recruiter, | |
| 245 | 'missionday' => $this->missionday, | |
| 246 | 'nl1331_meetups' => $this->nl1331Meetups, | |
| 247 | 'ifs' => $this->ifs, | |
| 248 | 'current_challenge' => $this->currentChallenge, | |
| 249 | 'scout' => $this->scout, | |
| 250 | 'scout_controller' => $this->scoutController, | |
| 251 | 'longest_link' => $this->longestLink, | |
| 252 | 'largest_field' => $this->largestField, | |
| 253 | 'recursions' => $this->recursions, | |
| 254 | 'drone_flight_distance' => $this->droneFlightDistance, | |
| 255 | 'maverick' => $this->maverick, | |
| 256 | 'drone_portals_visited' => $this->dronePortalsVisited, | |
| 257 | 'drone_forced_recalls' => $this->droneForcedRecalls, | |
| 258 | 'kinetic_capsules_completed' => $this->kineticCapsulesCompleted, | |
| 259 | 'months_subscribed' => $this->monthsSubscribed, | |
| 260 | 'epoch' => $this->epoch, | |
| 261 | 'portals_discovered' => $this->portalsDiscovered, | |
| 262 | 'drones_returned' => $this->dronesReturned, | |
| 263 | 'second_sunday' => $this->secondSunday, | |
| 264 | 'reclaimer' => $this->reclaimer, | |
| 265 | ]; | |
| 266 | } | |
| 267 | } |