Skip to content

Commit fb8725e

Browse files
authored
Deprecate the CompanyBan model (#46)
* Deprecate the CompanyBan model * Replace the usage of CompanyBan with CompanyMember
1 parent 15845eb commit fb8725e

File tree

4 files changed

+14
-145
lines changed

4 files changed

+14
-145
lines changed

src/Models/CompanyBan.php

Lines changed: 8 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -2,143 +2,13 @@
22

33
namespace TruckersMP\APIClient\Models;
44

5-
use Carbon\Carbon;
6-
7-
class CompanyBan
5+
/**
6+
* This represents a banned company member.
7+
*
8+
* @deprecated This model is identical to CompanyMember and will be removed in
9+
* the next major version. Please, avoid using it in your project.
10+
* @see CompanyMember
11+
*/
12+
class CompanyBan extends CompanyMember
813
{
9-
/**
10-
* The player's member ID within the company.
11-
*
12-
* @var int
13-
*/
14-
protected $id;
15-
16-
/**
17-
* The ID of the user.
18-
*
19-
* @var int
20-
*/
21-
protected $userId;
22-
23-
/**
24-
* The username of the user.
25-
*
26-
* @var string
27-
*/
28-
protected $username;
29-
30-
/**
31-
* The Steam ID of the user.
32-
*
33-
* @var int
34-
*/
35-
protected $steamId;
36-
37-
/**
38-
* The player's role ID within the company.
39-
*
40-
* @var int
41-
*/
42-
protected $roleId;
43-
44-
/**
45-
* The player's role name within the company.
46-
*
47-
* @var string
48-
*/
49-
protected $roleName;
50-
51-
/**
52-
* The date at which the user joined the company.
53-
*
54-
* @var Carbon
55-
*/
56-
protected $joinDate;
57-
58-
/**
59-
* Create a new CompanyBan instance.
60-
*
61-
* @param array $ban
62-
* @return void
63-
*/
64-
public function __construct(array $ban)
65-
{
66-
$this->id = $ban['id'];
67-
$this->userId = $ban['user_id'];
68-
$this->username = $ban['username'];
69-
$this->steamId = $ban['steam_id'];
70-
$this->roleId = $ban['role_id'];
71-
$this->roleName = $ban['role'];
72-
$this->joinDate = new Carbon($ban['joinDate'], 'UTC');
73-
}
74-
75-
/**
76-
* Get the player's member ID within the company.
77-
*
78-
* @return int
79-
*/
80-
public function getId(): int
81-
{
82-
return $this->id;
83-
}
84-
85-
/**
86-
* Get the ID of the user.
87-
*
88-
* @return int
89-
*/
90-
public function getUserId(): int
91-
{
92-
return $this->userId;
93-
}
94-
95-
/**
96-
* Get the username of the user.
97-
*
98-
* @return string
99-
*/
100-
public function getUsername(): string
101-
{
102-
return $this->username;
103-
}
104-
105-
/**
106-
* Get the Steam ID of the user.
107-
*
108-
* @return int
109-
*/
110-
public function getSteamId(): int
111-
{
112-
return $this->steamId;
113-
}
114-
115-
/**
116-
* Get the ID of the member's role within the company.
117-
*
118-
* @return int
119-
*/
120-
public function getRoleId(): int
121-
{
122-
return $this->roleId;
123-
}
124-
125-
/**
126-
* Get the name of the member's role within the company.
127-
*
128-
* @return string
129-
*/
130-
public function getRoleName(): string
131-
{
132-
return $this->roleName;
133-
}
134-
135-
/**
136-
* Get the date the member joined the company.
137-
*
138-
* @return Carbon
139-
*/
140-
public function getJoinDate(): Carbon
141-
{
142-
return $this->joinDate;
143-
}
14414
}

src/Requests/Company/BanIndexRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Support\Collection;
66
use Psr\Http\Client\ClientExceptionInterface;
77
use TruckersMP\APIClient\Exceptions\ApiErrorException;
8-
use TruckersMP\APIClient\Models\CompanyBan;
8+
use TruckersMP\APIClient\Models\CompanyMember;
99
use TruckersMP\APIClient\Requests\Request;
1010

1111
class BanIndexRequest extends Request
@@ -43,14 +43,14 @@ public function getEndpoint(): string
4343
/**
4444
* Get the data for the request.
4545
*
46-
* @return Collection|CompanyBan[]
46+
* @return Collection|CompanyMember[]
4747
*
4848
* @throws ApiErrorException
4949
* @throws ClientExceptionInterface
5050
*/
5151
public function get(): Collection
5252
{
5353
return (new Collection($this->send()['response']['members']))
54-
->mapInto(CompanyBan::class);
54+
->mapInto(CompanyMember::class);
5555
}
5656
}

tests/TestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use TruckersMP\APIClient\Exceptions\ApiErrorException;
2121
use TruckersMP\APIClient\Models\Ban;
2222
use TruckersMP\APIClient\Models\Company;
23-
use TruckersMP\APIClient\Models\CompanyBan;
2423
use TruckersMP\APIClient\Models\CompanyEventIndex;
2524
use TruckersMP\APIClient\Models\CompanyIndex;
2625
use TruckersMP\APIClient\Models\CompanyMember;
@@ -399,7 +398,7 @@ public function companyMember(int $companyId, int $memberId): CompanyMember
399398
* Get the members within the specified company that are currently banned.
400399
*
401400
* @param int $id
402-
* @return Collection|CompanyBan[]
401+
* @return Collection|CompanyMember[]
403402
*
404403
* @throws PhpfastcacheInvalidArgumentException
405404
* @throws ApiErrorException

tests/Unit/CompanyBanTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Support\Collection;
66
use Tests\TestCase;
7-
use TruckersMP\APIClient\Models\CompanyBan;
7+
use TruckersMP\APIClient\Models\CompanyMember;
88

99
class CompanyBanTest extends TestCase
1010
{
@@ -23,7 +23,7 @@ public function it_can_get_all_the_bans()
2323
if ($bans->count() > 0) {
2424
$ban = $bans[0];
2525

26-
$this->assertInstanceOf(CompanyBan::class, $ban);
26+
$this->assertInstanceOf(CompanyMember::class, $ban);
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)