supernova-ws /
SuperNova
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Created by Gorlum 28.11.2017 11:15 |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace Alliance; |
||
| 7 | |||
| 8 | |||
| 9 | use Player\RecordPlayer; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Class AllianceMember |
||
| 13 | * |
||
| 14 | * Class represents member of Alliance |
||
| 15 | * |
||
| 16 | * @package Alliance |
||
| 17 | */ |
||
| 18 | class AllianceMember { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var AllianceTitle $title |
||
| 22 | */ |
||
| 23 | protected $title; |
||
| 24 | /** |
||
| 25 | * @var array $player |
||
| 26 | */ |
||
| 27 | public $player; |
||
| 28 | /** |
||
| 29 | * @var Alliance $alliance |
||
| 30 | */ |
||
| 31 | protected $alliance; |
||
| 32 | |||
| 33 | |||
| 34 | public function __construct(Alliance $alliance, RecordPlayer $player) { |
||
| 35 | $this->alliance = $alliance; |
||
| 36 | $this->player = $player; |
||
|
0 ignored issues
–
show
|
|||
| 37 | |||
| 38 | $this->title = $this->alliance->getTitleList()->getTitle($this->isOwner() ? Alliance::OWNER_INDEX : $this->player->ally_rank_id); |
||
|
0 ignored issues
–
show
The property
ally_rank_id does not exist on Player\RecordPlayer. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Change title of member |
||
| 43 | * |
||
| 44 | * @param AllianceTitle $title |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | public function changeTitle(AllianceTitle $title) { |
||
| 49 | if(!$title instanceof AllianceTitle) { |
||
|
0 ignored issues
–
show
|
|||
| 50 | return false; |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->player->ally_rank_id = $title->index; |
||
| 54 | |||
| 55 | return $this->player->update(); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Get player ID of member |
||
| 60 | * |
||
| 61 | * @return mixed |
||
| 62 | */ |
||
| 63 | public function getPlayerId() { |
||
| 64 | return $this->player->id; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return mixed |
||
| 69 | */ |
||
| 70 | public function getMemberName() { |
||
| 71 | return $this->player->username; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return bool |
||
| 76 | */ |
||
| 77 | public function isOwner() { |
||
| 78 | return $this->getPlayerId() == $this->alliance->ownerId; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @return array |
||
| 83 | */ |
||
| 84 | public function asPtl() { |
||
| 85 | return [ |
||
| 86 | 'PLAYER_ID' => $this->getPlayerId(), |
||
| 87 | 'PLAYER_NAME' => $this->player->username, |
||
| 88 | 'ONLINE' => $this->player->onlinetime, |
||
| 89 | 'ONLINE_SQL' => date(FMT_DATE_TIME_SQL, $this->player->onlinetime), |
||
| 90 | 'VACATION' => $this->player->vacation, |
||
| 91 | 'VACATION_SQL' => date(FMT_DATE_TIME_SQL, $this->player->vacation), |
||
| 92 | 'BAN' => $this->player->banaday, |
||
| 93 | 'BAN_SQL' => date(FMT_DATE_TIME_SQL, $this->player->banaday), |
||
| 94 | 'TITLE' => $this->title->name, |
||
| 95 | 'TITLE_ID' => $this->title->index, |
||
| 96 | 'RIGHTS' => $this->title->rightsAsString(), |
||
| 97 | 'OWNER' => $this->isOwner(), |
||
| 98 | ]; |
||
| 99 | } |
||
| 100 | |||
| 101 | } |
||
| 102 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..