HarvestUser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 163
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 50
c 1
b 0
f 0
dl 0
loc 163
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 33 1
A getName() 0 3 1
1
<?php
2
/**
3
 * SaaS Link plugin for Craft CMS 3.x
4
 *
5
 * @link      https://workingconcept.com
6
 * @copyright Copyright (c) 2018 Working Concept Inc.
7
 */
8
9
namespace workingconcept\saaslink\models\harvest;
10
11
use craft\base\Model;
12
13
/**
14
 * Harvest User Model
15
 * https://help.getharvest.com/api-v2/users-api/users/users/
16
 */
17
18
class HarvestUser extends Model
19
{
20
    // Properties
21
    // =========================================================================
22
23
    /**
24
     * @var int Unique ID for the user.
25
     */
26
    public $id;
27
28
    /**
29
     * @var string The first name of the user.
30
     */
31
    public $first_name;
32
33
    /**
34
     * @var string The last name of the user.
35
     */
36
    public $last_name;
37
38
    /**
39
     * @var string The email address of the user.
40
     */
41
    public $email;
42
43
    /**
44
     * @var string The telephone number for the user.
45
     */
46
    public $telephone;
47
48
    /**
49
     * @var string The user’s timezone.
50
     */
51
    public $timezone;
52
53
    /**
54
     * @var bool Whether the user should be automatically added to future projects.
55
     */
56
    public $has_access_to_all_future_projects;
57
58
    /**
59
     * @var bool Whether the user is a contractor or an employee.
60
     */
61
    public $is_contractor;
62
63
    /**
64
     * @var bool Whether the user has admin permissions.
65
     */
66
    public $is_admin;
67
    
68
    /**
69
     * @var bool Whether the user has project manager permissions.
70
     */
71
    public $is_project_manager;
72
    
73
    /**
74
     * @var bool Whether the user can see billable rates on projects. Only applicable to project managers.
75
     */
76
    public $can_see_rates;
77
    
78
    /**
79
     * @var bool Whether the user can create projects. Only applicable to project managers.
80
     */
81
    public $can_create_projects;
82
    
83
    /**
84
     * @var bool Whether the user can create invoices. Only applicable to project managers.
85
     */
86
    public $can_create_invoices;
87
    
88
    /**
89
     * @var bool Whether the user is active or archived.
90
     */
91
    public $is_active;
92
    
93
    /**
94
     * @var int The number of hours per week this person is available to work in seconds,
95
     *              in half hour increments. For example, if a person’s capacity is 35 hours, 
96
     *              the API will return 126000 seconds.
97
     */
98
    public $weekly_capacity;
99
    
100
    /**
101
     * @var float The billable rate to use for this user when they are added to a project.
102
     */
103
    public $default_hourly_rate;
104
    
105
    /**
106
     * @var float The cost rate to use for this user when calculating a project’s costs vs billable amount.
107
     */
108
    public $cost_rate;
109
    
110
    /**
111
     * @var string[] The role names assigned to this person.
112
     */
113
    public $roles;
114
    
115
    /**
116
     * @var string The URL to the user’s avatar image.
117
     */
118
    public $avatar_url;
119
    
120
    /**
121
     * @var string Date and time the user was created.
122
     */
123
    public $created_at;
124
    
125
    /**
126
     * @var string Date and time the user was last updated.
127
     */
128
    public $updated_at;
129
130
131
    // Public Methods
132
    // =========================================================================
133
134
135
    /**
136
     * Get the user's full name.
137
     *
138
     * @return string
139
     */
140
    public function getName(): string
141
    {
142
        return $this->first_name . ' ' . $this->last_name;
143
    }
144
145
    /**
146
     * @inheritdoc
147
     */
148
    public function rules(): array
149
    {
150
        return [
151
            [[
152
                'id', 
153
                'weekly_capacity'
154
             ], 'number', 'integerOnly' => true],
155
            [[
156
                'default_hourly_rate', 
157
                'cost_rate'
158
             ], 'number', 'integerOnly' => false],
159
            [['id'], 'required'],
160
            [[
161
                'first_name', 
162
                'last_name', 
163
                'email', 
164
                'telephone', 
165
                'timezone', 
166
                'avatar_url', 
167
                'created_at', 
168
                'updated_at'
169
             ], 'string'],
170
            [[
171
                'has_access_to_all_future_projects', 
172
                'is_contractor', 
173
                'is_admin', 
174
                'is_project_manager', 
175
                'can_see_rates', 
176
                'can_create_projects', 
177
                'can_create_invoices', 
178
                'is_active'
179
             ], 'boolean'],
180
            ['roles', 'each', 'rule' => ['string']],
181
        ];
182
    }
183
184
}
185