Passed
Branch master (182172)
by Matthew
04:03 queued 01:23
created

DraftRepository::MoveDraftForward()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 18
nc 4
nop 2
1
<?php
2
namespace PhpDraft\Domain\Repositories;
3
4
use Silex\Application;
5
use Symfony\Component\HttpFoundation\Request;
6
use PhpDraft\Domain\Entities\Draft;
7
use PhpDraft\Domain\Entities\Pick;
8
9
class DraftRepository {
10
  private $app;
11
12
  public function __construct(Application $app) {
13
    $this->app = $app;
14
  }
15
16
  //TODO: Add server-side paging
17
  public function GetPublicDrafts(Request $request/*$pageSize = 25, $page = 1*/, $password = '') {
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
    /*$page = (int)$page;
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
    $pageSize = (int)$pageSize;
20
    $startIndex = ($page-1) * $pageSize;
21
22
    if($startIndex < 0) {
23
      throw new \Exception("Unable to get drafts: incorrect paging parameters.");
24
    }*/
25
26
    //$draft_stmt = $this->app['db']->prepare("SELECT * FROM draft ORDER BY draft_create_time LIMIT ?, ?");
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
    $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d 
28
      LEFT OUTER JOIN users u 
29
      ON d.commish_id = u.id 
30
      ORDER BY draft_create_time DESC");
31
32
    $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft');
33
34
    $current_user = $this->app['phpdraft.LoginUserService']->GetUserFromHeaderToken($request);
35
36
    /*$draft_stmt->bindParam(1, $startIndex, \PDO::PARAM_INT);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
    $draft_stmt->bindParam(2, $pageSize, \PDO::PARAM_INT);*/
38
39
    if(!$draft_stmt->execute()) {
40
      throw new \Exception("Unable to load drafts.");
41
    }
42
43
    $drafts = array();
44
45
    while($draft = $draft_stmt->fetch()) {
46
      $currentUserOwnsIt = !empty($current_user) && $draft->commish_id == $current_user->id;
47
      $currentUserIsAdmin = !empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user);
48
49
      $draft->draft_visible = empty($draft->draft_password);
50
      $draft->commish_editable = $currentUserOwnsIt || $currentUserIsAdmin;
51
      $draft->setting_up = $this->app['phpdraft.DraftService']->DraftSettingUp($draft);
52
      $draft->in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft);
53
      $draft->complete = $this->app['phpdraft.DraftService']->DraftComplete($draft);
54
      $draft->is_locked = false;
55
56
      $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time);
57
      $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time);
58
      $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time);
59
60
      if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) {
61
        $draft->is_locked = true;
62
        $draft = $this->ProtectPrivateDraft($draft);
63
      }
64
65
      unset($draft->draft_password);
66
67
      $drafts[] = $draft;
68
    }
69
70
    return $drafts;
71
  }
72
73
  public function GetPublicDraftsByCommish(Request $request, $commish_id, $password = '') {
74
    $commish_id = (int)$commish_id;
75
76
    $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d
77
    LEFT OUTER JOIN users u
78
    ON d.commish_id = u.id
79
    WHERE commish_id = ?
80
    ORDER BY draft_create_time DESC");
81
82
    $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft');
83
    $draft_stmt->bindParam(1, $commish_id);
84
85
    if(!$draft_stmt->execute()) {
86
      throw new \Exception("Unable to load drafts.");
87
    }
88
89
    $current_user = $this->app['phpdraft.LoginUserService']->GetUserFromHeaderToken($request);
90
91
    $drafts = array();
92
93
    while($draft = $draft_stmt->fetch()) {
94
      $currentUserOwnsIt = !empty($current_user) && $draft->commish_id == $current_user->id;
95
      $currentUserIsAdmin = !empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user);
96
97
      $draft->draft_visible = empty($draft->draft_password);
98
      $draft->commish_editable = $currentUserOwnsIt || $currentUserIsAdmin;
99
      $draft->setting_up = $this->app['phpdraft.DraftService']->DraftSettingUp($draft);
100
      $draft->in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft);
101
      $draft->complete = $this->app['phpdraft.DraftService']->DraftComplete($draft);
102
      $draft->is_locked = false;
103
104
      $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time);
105
      $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time);
106
      $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time);
107
108
      if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) {
109
        $draft->is_locked = true;
110
        $draft = $this->ProtectPrivateDraft($draft);
111
      }
112
113
      unset($draft->draft_password);
114
115
      $drafts[] = $draft;
116
    }
117
118
    return $drafts;
119
  }
120
121
  //Note: this method is to be used by admin section only
122
  public function GetAllDraftsByCommish($commish_id) {
123
    $commish_id = (int)$commish_id;
124
125
    $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d
126
    LEFT OUTER JOIN users u
127
    ON d.commish_id = u.id
128
    WHERE commish_id = ?
129
    ORDER BY draft_create_time DESC");
130
131
    $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft');
132
    $draft_stmt->bindParam(1, $commish_id);
133
134
    if(!$draft_stmt->execute()) {
135
      throw new \Exception("Unable to load drafts.");
136
    }
137
138
    $drafts = array();
139
140
    while($draft = $draft_stmt->fetch()) {
141
      $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time);
142
      $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time);
143
      $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time);
144
145
      $drafts[] = $draft;
146
    }
147
148
    return $drafts;
149
  }
150
151
  //Note: this method is to be used by admin section only
152
  public function GetAllCompletedDrafts() {
153
    $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d
154
      LEFT OUTER JOIN users u
155
      ON d.commish_id = u.id
156
      WHERE d.draft_status = 'complete'
157
      ORDER BY draft_create_time DESC");
158
159
    $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft');
160
161
    if(!$draft_stmt->execute()) {
162
      throw new \Exception("Unable to load drafts.");
163
    }
164
165
    $drafts = array();
166
167
    while($draft = $draft_stmt->fetch()) {
168
      $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time);
169
      $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time);
170
      $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time);
171
172
      $drafts[] = $draft;
173
    }
174
175
    return $drafts;
176
  }
177
178
  public function GetPublicDraft(Request $request, $id, $getDraftData = false, $password = '') {
179
    $draft = new Draft();
180
181
    $cachedDraft = $this->GetCachedDraft($id);
182
183
    if($cachedDraft != null) {
184
      $draft = $cachedDraft;
185
    } else {
186
      $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d
187
        LEFT OUTER JOIN users u
188
        ON d.commish_id = u.id
189
        WHERE d.draft_id = ? LIMIT 1");
190
      $draft_stmt->setFetchMode(\PDO::FETCH_INTO, $draft);
191
192
      $draft_stmt->bindParam(1, $id, \PDO::PARAM_INT);
193
194
      if(!$draft_stmt->execute() || !$draft_stmt->fetch()) {
195
        throw new \Exception("Unable to load draft");
196
      }
197
198
      $draft->using_depth_charts = $draft->using_depth_charts == 1;
199
200
      $this->SetCachedDraft($draft);
201
    }
202
203
    $current_user = $this->app['phpdraft.LoginUserService']->GetUserFromHeaderToken($request);
204
205
    $currentUserOwnsIt = !empty($current_user) && $draft->commish_id == $current_user->id;
206
    $currentUserIsAdmin = !empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user);
207
208
    $draft->draft_visible = empty($draft->draft_password);
209
    $draft->commish_editable = $currentUserOwnsIt || $currentUserIsAdmin;
210
211
    $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time);
212
    $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time);
213
    $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time);
214
215
    $draft->setting_up = $this->app['phpdraft.DraftService']->DraftSettingUp($draft);
216
    $draft->in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft);
217
    $draft->complete = $this->app['phpdraft.DraftService']->DraftComplete($draft);
218
219
    if($getDraftData) {
220
      $draft->sports = $this->app['phpdraft.DraftDataRepository']->GetSports();
221
      $draft->styles = $this->app['phpdraft.DraftDataRepository']->GetStyles();
222
      $draft->statuses = $this->app['phpdraft.DraftDataRepository']->GetStatuses();
223
      $draft->teams = $this->app['phpdraft.DraftDataRepository']->GetTeams($draft->draft_sport);
224
      $draft->historical_teams = $this->app['phpdraft.DraftDataRepository']->GetHistoricalTeams($draft->draft_sport);
225
      $draft->positions = $this->app['phpdraft.DraftDataRepository']->GetPositions($draft->draft_sport);
226
      if($draft->using_depth_charts) {
227
        $draft->depthChartPositions = $this->app['phpdraft.DepthChartPositionRepository']->LoadAll($draft->draft_id);
228
      }
229
    }
230
231
    $draft->is_locked = false;
232
233
    if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) {
234
      $draft->is_locked = true;
235
      $draft = $this->ProtectPrivateDraft($draft);
236
    }
237
238
    unset($draft->draft_password);
239
240
    return $draft;
241
  }
242
243
  /*
244
  * This method is only to be used internally or when the user has been verified as owner of the draft (or is admin)
245
  * (in other words, don't call this then return the result as JSON!)
246
  */
247
  public function Load($id, $bustCache = false) {
248
    $draft = new Draft();
249
250
    $cachedDraft = $this->GetCachedDraft($id);
251
252
    if($bustCache || $cachedDraft == null) {
253
      $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d
254
      LEFT OUTER JOIN users u
255
      ON d.commish_id = u.id
256
      WHERE draft_id = ? LIMIT 1");
257
258
      $draft_stmt->setFetchMode(\PDO::FETCH_INTO, $draft);
259
260
      $draft_stmt->bindParam(1, $id, \PDO::PARAM_INT);
261
262
      if(!$draft_stmt->execute() || !$draft_stmt->fetch()) {
263
        throw new \Exception("Unable to load draft");
264
      }
265
266
      $draft->using_depth_charts = $draft->using_depth_charts == 1;
267
268
      if($bustCache) {
269
        $this->UnsetCachedDraft($draft->draft_id);
270
      }
271
272
      $this->SetCachedDraft($draft);
273
    } else {
274
      $draft = $cachedDraft;
275
    }
276
277
    $draft->draft_rounds = (int)$draft->draft_rounds;
278
279
    return $draft;
280
  }
281
282
  public function Create(Draft $draft) {
283
    $insert_stmt = $this->app['db']->prepare("INSERT INTO draft
284
      (draft_id, commish_id, draft_create_time, draft_name, draft_sport, draft_status, draft_style, draft_rounds, draft_password, using_depth_charts)
285
      VALUES
286
      (NULL, ?, UTC_TIMESTAMP(), ?, ?, ?, ?, ?, ?, ?)");
287
288
    $insert_stmt->bindParam(1, $draft->commish_id);
289
    $insert_stmt->bindParam(2, $draft->draft_name);
290
    $insert_stmt->bindParam(3, $draft->draft_sport);
291
    $insert_stmt->bindParam(4, $draft->draft_status);
292
    $insert_stmt->bindParam(5, $draft->draft_style);
293
    $insert_stmt->bindParam(6, $draft->draft_rounds);
294
    $insert_stmt->bindParam(7, $draft->draft_password);
295
    $insert_stmt->bindParam(8, $draft->using_depth_charts);
296
297
    if(!$insert_stmt->execute()) {
298
      throw new \Exception("Unable to create draft.");
299
    }
300
301
    $draft = $this->Load((int)$this->app['db']->lastInsertId(), true);
302
303
    return $draft;
304
  }
305
306
  //Excluded properties in update:
307
  //draft_start_time/draft_end_time - updated in separate operations at start/end of draft
308
  //draft_current_round/draft_current_pick - updated when new picks are made
309
  //draft_counter - call IncrementDraftCounter instead - this call's made a lot independently of other properties.
310
  //draft_status - separate API call to update the draft status
311
  public function Update(Draft $draft) {
312
    $update_stmt = $this->app['db']->prepare("UPDATE draft
313
      SET commish_id = ?, draft_name = ?, draft_sport = ?,
314
      draft_style = ?, draft_password = ?, draft_rounds = ?,
315
      using_depth_charts = ?
316
      WHERE draft_id = ?");
317
318
    $draft->using_depth_charts = $draft->using_depth_charts;
319
320
    $update_stmt->bindParam(1, $draft->commish_id);
321
    $update_stmt->bindParam(2, $draft->draft_name);
322
    $update_stmt->bindParam(3, $draft->draft_sport);
323
    $update_stmt->bindParam(4, $draft->draft_style);
324
    $update_stmt->bindParam(5, $draft->draft_password);
325
    $update_stmt->bindParam(6, $draft->draft_rounds);
326
    $update_stmt->bindParam(7, $draft->using_depth_charts);
327
    $update_stmt->bindParam(8, $draft->draft_id);
328
329
    if(!$update_stmt->execute()) {
330
      throw new \Exception("Unable to update draft.");
331
    }
332
333
    $this->ResetDraftCache($draft->draft_id);
334
335
    return $draft;
336
  }
337
338
  public function UpdateStatus(Draft $draft) {
339
    $status_stmt = $this->app['db']->prepare("UPDATE draft
340
      SET draft_status = ? WHERE draft_id = ?");
341
342
    $status_stmt->bindParam(1, $draft->draft_status);
343
    $status_stmt->bindParam(2, $draft->draft_id);
344
345
    if(!$status_stmt->execute()) {
346
      throw new \Exception("Unable to update draft status.");
347
    }
348
349
    $this->ResetDraftCache($draft->draft_id);
350
351
    return $draft;
352
  }
353
354
  public function UpdateStatsTimestamp(Draft $draft) {
355
    $status_stmt = $this->app['db']->prepare("UPDATE draft
356
      SET draft_stats_generated = UTC_TIMESTAMP() WHERE draft_id = ?");
357
358
    $status_stmt->bindParam(1, $draft->draft_id);
359
360
    if(!$status_stmt->execute()) {
361
      throw new \Exception("Unable to update draft's stats timestamp.");
362
    }
363
364
    $this->ResetDraftCache($draft->draft_id);
365
366
    return $draft;
367
  }
368
369
  public function IncrementDraftCounter(Draft $draft) {
370
    $incrementedCounter = (int)$draft->draft_counter + 1;
371
372
    $increment_stmt = $this->app['db']->prepare("UPDATE draft
373
      SET draft_counter = ? WHERE draft_id = ?");
374
375
    $increment_stmt->bindParam(1, $incrementedCounter);
376
    $increment_stmt->bindParam(2, $draft->draft_id);
377
378
    if(!$increment_stmt->execute()) {
379
      throw new \Exception("Unable to increment draft counter.");
380
    }
381
382
    $this->ResetDraftCache($draft->draft_id);
383
384
    return $incrementedCounter;
385
  }
386
387
  //$next_pick can't be type-hinted - can be null
388
  public function MoveDraftForward(Draft $draft, $next_pick) {
389
    if ($next_pick !== null) {
390
      $draft->draft_current_pick = (int) $next_pick->player_pick;
391
      $draft->draft_current_round = (int) $next_pick->player_round;
392
393
      $stmt = $this->app['db']->prepare("UPDATE draft SET draft_current_pick = ?, draft_current_round = ? WHERE draft_id = ?");
394
      $stmt->bindParam(1, $draft->draft_current_pick);
395
      $stmt->bindParam(2, $draft->draft_current_round);
396
      $stmt->bindParam(3, $draft->draft_id);
397
398
      if (!$stmt->execute()) {
399
        throw new \Exception("Unable to move draft forward.");
400
      }
401
    } else {
402
      $draft->draft_status = 'complete';
403
      $stmt = $this->app['db']->prepare("UPDATE draft SET draft_status = ?, draft_end_time = UTC_TIMESTAMP() WHERE draft_id = ?");
404
      $stmt->bindParam(1, $draft->draft_status);
405
      $stmt->bindParam(2, $draft->draft_id);
406
407
      if (!$stmt->execute()) {
408
        throw new \Exception("Unable to move draft forward.");
409
      }
410
    }
411
412
    $this->ResetDraftCache($draft->draft_id);
413
414
    return $draft;
415
  }
416
417
  //Used when we move a draft from "undrafted" to "in_progress":
418
  //Resets the draft counter
419
  //Sets the current pick and round to 1
420
  //Sets the draft start time to UTC now, nulls out end time
421
  public function SetDraftInProgress(Draft $draft) {
422
    $reset_stmt = $this->app['db']->prepare("UPDATE draft
423
      SET draft_counter = 0, draft_current_pick = 1, draft_current_round = 1,
424
      draft_start_time = UTC_TIMESTAMP(), draft_end_time = NULL
425
      WHERE draft_id = ?");
426
427
    $reset_stmt->bindParam(1, $draft->draft_id);
428
429
    if(!$reset_stmt->execute()) {
430
      throw new \Exception("Unable to set draft to in progress.");
431
    }
432
433
    $this->ResetDraftCache($draft->draft_id);
434
435
    return 0;
436
  }
437
438
  public function NameIsUnique($name, $id = null) {
439
    if(!empty($id)) {
440
      $name_stmt = $this->app['db']->prepare("SELECT draft_name FROM draft WHERE draft_name LIKE ? AND draft_id <> ?");
441
      $name_stmt->bindParam(1, $name);
442
      $name_stmt->bindParam(2, $id);
443
    } else {
444
      $name_stmt = $this->app['db']->prepare("SELECT draft_name FROM draft WHERE draft_name LIKE ?");
445
      $name_stmt->bindParam(1, $name);
446
    }
447
448
    if(!$name_stmt->execute()) {
449
      throw new \Exception("Draft name '%s' is invalid", $name);
450
    }
451
452
    return $name_stmt->rowCount() == 0;
453
  }
454
455
  public function DeleteDraft($draft_id) {
456
    $delete_stmt = $this->app['db']->prepare("DELETE FROM draft WHERE draft_id = ?");
457
    $delete_stmt->bindParam(1, $draft_id);
458
459
    if(!$delete_stmt->execute()) {
460
      throw new \Exception("Unable to delete draft $draft_id.");
461
    }
462
463
    $this->UnsetCachedDraft($draft_id);
464
465
    return;
466
  }
467
468
  private function ResetDraftCache($draft_id) {
469
    $draft = $this->Load($draft_id, true);
0 ignored issues
show
Unused Code introduced by
The assignment to $draft is dead and can be removed.
Loading history...
470
  }
471
472
  private function SetCachedDraft(Draft $draft) {
473
    $this->app['phpdraft.DatabaseCacheService']->SetCachedItem("draft$draft->draft_id", $draft);
474
  }
475
476
  private function GetCachedDraft($draft_id) {
477
    return $this->app['phpdraft.DatabaseCacheService']->GetCachedItem("draft$draft_id");
478
  }
479
480
  private function UnsetCachedDraft($draft_id) {
481
    $this->app['phpdraft.DatabaseCacheService']->DeleteCachedItem("draft$draft_id");
482
  }
483
484
  private function ProtectPrivateDraft(Draft $draft) {
485
    $draft->draft_sport = '';
486
    $draft->draft_status = '';
487
    $draft->setting_up = '';
0 ignored issues
show
Bug introduced by
The property setting_up does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
488
    $draft->in_progress = '';
0 ignored issues
show
Bug introduced by
The property in_progress does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
489
    $draft->complete = '';
0 ignored issues
show
Bug introduced by
The property complete does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
490
    $draft->draft_style = '';
491
    $draft->draft_rounds = '';
0 ignored issues
show
Documentation Bug introduced by
The property $draft_rounds was declared of type integer, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
492
    $draft->draft_counter = '';
0 ignored issues
show
Documentation Bug introduced by
The property $draft_counter was declared of type integer, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
493
    $draft->draft_start_time = null;
494
    $draft->draft_end_time = null;
495
    $draft->draft_current_pick = '';
0 ignored issues
show
Documentation Bug introduced by
The property $draft_current_pick was declared of type integer, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
496
    $draft->draft_current_round = '';
0 ignored issues
show
Documentation Bug introduced by
The property $draft_current_round was declared of type integer, but '' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
497
    $draft->draft_create_time = '';
0 ignored issues
show
Bug introduced by
The property draft_create_time does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
498
    $draft->draft_stats_generated = '';
499
    $draft->nfl_extended = null;
500
    $draft->sports = null;
501
    $draft->styles = null;
502
    $draft->statuses = null;
503
    $draft->teams = null;
0 ignored issues
show
Bug introduced by
The property teams does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
504
    $draft->positions = null;
0 ignored issues
show
Bug introduced by
The property positions does not exist on PhpDraft\Domain\Entities\Draft. Did you mean sports_positions?
Loading history...
505
    $draft->using_depth_charts = null;
506
    $draft->depthChartPositions = null;
0 ignored issues
show
Bug introduced by
The property depthChartPositions does not seem to exist on PhpDraft\Domain\Entities\Draft.
Loading history...
507
508
    return $draft;
509
  }
510
}