Completed
Push — work-fleets ( 5c3a01...351cf4 )
by SuperNova.WS
06:40
created

BuddyParams::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
nc 1
nop 1
dl 0
loc 19
rs 9.4285
c 1
b 0
f 0
ccs 0
cts 15
cp 0
crap 2
1
<?php
2
/**
3
 * Created by Gorlum 12.08.2016 21:12
4
 */
5
6
namespace Buddy;
7
8
/**
9
 * Class BuddyParams
10
 * @package Buddy
11
 *
12
 * @property int|float        $buddy_id
13
 * @property string           $mode
14
 * @property int|float        $newFriendIdSafe
15
 * @property string           $new_friend_name_unsafe
16
 * @property string           $request_text_unsafe
17
 *
18
 * @property array            $playerArray - optional. Unfortunately - we need full record to get name and capital coordinates for buddy message
19
 * @property int|float        $playerId
20
 * @property string           $playerName
21
 * @property string           $playerNameAndCoordinates
22
 */
23
class BuddyParams extends \ContainerAccessors {
24
25
  /**
26
   * BuddyParams constructor.
27
   *
28
   * @param array $user
29
   */
30
  public function __construct($user = array()) {
31
    $this->buddy_id = sys_get_param_id('buddy_id');
32
    $this->mode = sys_get_param_str('mode');
33
    $this->newFriendIdSafe = sys_get_param_id('request_user_id');
34
    $this->new_friend_name_unsafe = sys_get_param_str_unsafe('request_user_name');
35
    $this->request_text_unsafe = sys_get_param_str_unsafe('request_text');
36
37
    $this->playerArray = $user;
38
39
    $this->playerId = function (BuddyParams $cBuddy) {
40
      return $cBuddy->playerArray['id'];
41
    };
42
    $this->playerName = function (BuddyParams $cBuddy) {
43
      return $cBuddy->playerArray['username'];
44
    };
45
    $this->playerNameAndCoordinates = function (BuddyParams $cBuddy) {
46
      return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray);
47
    };
48
  }
49
50
}
51