Add updated_at column to accounts
[gamestick-pjgsapi.git] / src / Profile.php
1 <?php
2 /**
3  * Database row from the "gamesticks" table
4  */
5 class Profile
6 {
7     protected string $avatarDir;
8
9     public int $id;
10     public string $hwId;
11     public string $sessionId;
12     public ?string $verificationCode;
13     public ?string $gamerTag;
14     public bool $founderFlag;
15     public ?string $founderName;
16     public int $minAge;
17     public ?string $avatar;
18
19     public string $created_at;
20     public string $updated_at;
21
22     public function __construct()
23     {
24         $this->avatarDir = dirname(__FILE__) . '/../www/resources/avatars/';
25     }
26
27     public function complete(): bool
28     {
29         return $this->gamerTag !== null;
30     }
31
32     public function getAvatarLargeUrl(): string
33     {
34         if (strpos($this->avatar, '://')) {
35             return $this->avatar;
36         }
37
38         if (file_exists($this->avatarDir . $this->avatar . '.large.jpg')) {
39             $ext = 'jpg';
40         } else {
41             $ext = 'png';
42         }
43
44         return 'http://l2.gamestickservices.net/resources/avatars/'
45             . $this->avatar . '.large.' . $ext;
46     }
47
48     public function getAvatarSmallUrl(): string
49     {
50         if (strpos($this->avatar, '://')) {
51             return $this->avatar;
52         }
53
54         if (file_exists($this->avatarDir . $this->avatar . '.small.jpg')) {
55             $ext = 'jpg';
56         } else {
57             $ext = 'png';
58         }
59
60         return 'http://l2.gamestickservices.net/resources/avatars/'
61             . $this->avatar . '.small.' . $ext;
62     }
63 }