Completed
Push — master ( ef29db...6cb927 )
by Ariel
06:10
created

Concierge::vacancyCalendar()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Timegridio\Concierge;
4
5
use Carbon\Carbon;
6
use Timegridio\Concierge\Booking\Strategies\BookingStrategy;
7
use Timegridio\Concierge\Calendar\VacancyCalendar;
8
use Timegridio\Concierge\Models\Business;
9
use Timegridio\Concierge\Models\Service;
10
11
/*******************************************************************************
12
 * Concierge Service Layer
13
 *     High level booking manager
14
 ******************************************************************************/
15
class Concierge extends Workspace
16
{
17
    protected $strategy = null;
18
19
    protected $vacancyCalendar = null;
20
21
    protected function strategy()
22
    {
23
        if ($this->strategy === null) {
24
            $this->strategy = new BookingStrategy($this->business->strategy);
25
        }
26
27
        return $this->strategy;
28
    }
29
30
    protected function vacancyCalendar()
31
    {
32
        if ($this->vacancyCalendar === null) {
33
            $this->vacancyCalendar = new VacancyCalendar($this->strategy, $this->business->vacancies());
34
        }
35
36
        return $this->vacancyCalendar;
37
    }
38
39
    public function takeReservation($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        //        $datetime = $this->makeDateTimeUTC($request['date'], $request['time'], $request['timezone']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
42
//
43
//        $appointment = $this->strategy()->generateAppointment(
44
//            $request['issuer'],
45
//            $this->business,
46
//            $request['contact'],
47
//            $request['service'],
48
//            $datetime,
49
//            $request['comments']
50
//        );
51
//
52
//        if ($appointment->duplicates()) {
53
//            return $appointment;
54
//            // throw new \Exception('Duplicated Appointment Attempted');
55
//        }
56
//
57
//        $vacancy = $this->vacancyCalendar()->getSlotFor($appointment->start_at, $appointment->finish_at, $appointment->service->id);
58
//
59
//        if ($vacancy != null) {
60
//            $appointment->vacancy()->associate($vacancy);
61
//            $appointment->save();
62
//
63
//            return $appointment;
64
//        }
65
//
66
//        return false;
67
    }
68
69
    protected function makeDateTimeUTC($date, $time, $timezone = null)
70
    {
71
        if ($timezone === null) {
72
            $timezone = $this->business->timezone;
73
        }
74
75
        return Carbon::parse("{$date} {$time} {$timezone}")->timezone('UTC');
76
    }
77
}
78