TicketFetch::mailController()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Http\Controllers\Agent\helpdesk\MailController;
6
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
7
use Event;
8
use Illuminate\Console\Command;
9
10
class TicketFetch extends Command
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'ticket:fetch';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Fetching the tickets from service provider';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @return mixed
40
     */
41
    public function handle()
42
    {
43
        if (env('DB_INSTALL') == 1) {
44
            $controller = $this->mailController();
45
            $emails = new \App\Model\helpdesk\Email\Emails();
46
            $settings_email = new \App\Model\helpdesk\Settings\Email();
47
            $system = new \App\Model\helpdesk\Settings\System();
48
            $ticket = new \App\Model\helpdesk\Settings\Ticket();
49
            $controller->readmails($emails, $settings_email, $system, $ticket);
50
            Event::fire('ticket.fetch', ['event' => '']);
51
            loging('fetching-ticket', 'Ticket has read', 'info');
52
            //\Log::info('Ticket has read');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% 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...
53
            $this->info('Ticket has read');
54
        }
55
    }
56
57 View Code Duplication
    public function mailController()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
60
        $NotificationController = new \App\Http\Controllers\Common\NotificationController();
61
        $ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
62
        $work = new TicketWorkflowController($ticket);
63
        $controller = new MailController($work);
64
65
        return $controller;
66
    }
67
}
68