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

BuddyParams   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 28
rs 10
c 1
b 0
f 0
ccs 0
cts 15
cp 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
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