SettingsController::postticket()   B
last analyzed

Complexity

Conditions 2
Paths 13

Size

Total Lines 25
Code Lines 16

Duplication

Lines 25
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
nc 13
nop 3
dl 25
loc 25
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Admin\helpdesk;
4
5
// controllers
6
use App\Http\Controllers\Controller;
7
// requests
8
use App\Http\Requests\helpdesk\CompanyRequest;
9
use App\Http\Requests\helpdesk\EmailRequest;
10
use App\Http\Requests\helpdesk\Job\TaskRequest;
11
use App\Http\Requests\helpdesk\RatingUpdateRequest;
12
use App\Http\Requests\helpdesk\StatusRequest;
13
// models
14
use App\Http\Requests\helpdesk\SystemRequest;
15
use App\Model\helpdesk\Agent\Department;
16
use App\Model\helpdesk\Email\Emails;
17
use App\Model\helpdesk\Email\Template;
18
use App\Model\helpdesk\Manage\Help_topic;
19
use App\Model\helpdesk\Manage\Sla_plan;
20
use App\Model\helpdesk\Notification\UserNotification;
21
use App\Model\helpdesk\Ratings\Rating;
22
use App\Model\helpdesk\Settings\Alert;
23
use App\Model\helpdesk\Settings\CommonSettings;
24
use App\Model\helpdesk\Settings\Company;
25
use App\Model\helpdesk\Settings\Email;
26
use App\Model\helpdesk\Settings\Responder;
27
use App\Model\helpdesk\Settings\System;
28
use App\Model\helpdesk\Settings\Ticket;
29
use App\Model\helpdesk\Ticket\Ticket_Priority;
30
use App\Model\helpdesk\Utility\Date_format;
31
use App\Model\helpdesk\Utility\Date_time_format;
32
use App\Model\helpdesk\Utility\Time_format;
33
use App\Model\helpdesk\Utility\Timezones;
34
use App\Model\helpdesk\Workflow\WorkflowClose;
35
// classes
36
use DateTime;
37
use DB;
38
use Exception;
39
use File;
40
use Illuminate\Http\Request;
41
use Input;
42
use Lang;
43
44
/**
45
 * SettingsController.
46
 *
47
 * @author      Ladybird <[email protected]>
48
 */
49
class SettingsController extends Controller
50
{
51
    /**
52
     * Create a new controller instance.
53
     *
54
     * @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...
55
     */
56
    public function __construct()
57
    {
58
        // $this->smtp();
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...
59
        $this->middleware('auth');
60
        $this->middleware('roles');
61
    }
62
63
    /**
64
     * @param int $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
65
     * @param $compant instance of company table
66
     *
67
     * get the form for company setting page
68
     *
69
     * @return Response
70
     */
71
    public function getcompany(Company $company)
72
    {
73
        try {
74
            /* fetch the values of company from company table */
75
            $companys = $company->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Company>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
76
            /* Direct to Company Settings Page */
77
            return view('themes.default1.admin.helpdesk.settings.company', compact('companys'));
78
        } catch (Exception $e) {
79
            return redirect()->back()->with('fails', $e->getMessage());
80
        }
81
    }
82
83
    /**
84
     * Update the specified resource in storage.
85
     *
86
     * @param type int            $id
87
     * @param type Company        $company
88
     * @param type CompanyRequest $request
89
     *
90
     * @return Response
91
     */
92 View Code Duplication
    public function postcompany($id, Company $company, CompanyRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
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...
93
    {
94
        /* fetch the values of company request  */
95
        $companys = $company->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Company>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
96
        if (Input::file('logo')) {
97
            $name = Input::file('logo')->getClientOriginalName();
98
            $destinationPath = 'uploads/company/';
99
            $fileName = rand(0000, 9999).'.'.$name;
100
            Input::file('logo')->move($destinationPath, $fileName);
101
            $companys->logo = $fileName;
102
        }
103
        if ($request->input('use_logo') == null) {
104
            $companys->use_logo = '0';
105
        }
106
        /* Check whether function success or not */
107
        try {
108
            $companys->fill($request->except('logo'))->save();
109
            /* redirect to Index page with Success Message */
110
            return redirect('getcompany')->with('success', Lang::get('lang.company_updated_successfully'));
111
        } catch (Exception $e) {
112
            /* redirect to Index page with Fails Message */
113
            return redirect('getcompany')->with('fails', Lang::get('lang.company_can_not_updated').'<li>'.$e->getMessage().'</li>');
114
        }
115
    }
116
117
    /**
118
     * function to delete system logo.
119
     *
120
     *  @return type string
121
     */
122 View Code Duplication
    public function deleteLogo()
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...
123
    {
124
        $path = $_GET['data1']; //get file path of logo image
125
        if (!unlink($path)) {
126
            return 'false';
127
        } else {
128
            $companys = Company::where('id', '=', 1)->first();
129
            $companys->logo = null;
130
            $companys->use_logo = '0';
131
            $companys->save();
132
133
            return 'true';
134
        }
135
        // return $res;
136
    }
137
138
    /**
139
     * get the form for System setting page.
140
     *
141
     * @param type System           $system
142
     * @param type Department       $department
143
     * @param type Timezones        $timezone
144
     * @param type Date_format      $date
145
     * @param type Date_time_format $date_time
146
     * @param type Time_format      $time
147
     *
148
     * @return type Response
149
     */
150
    public function getsystem(System $system, Department $department, Timezones $timezone, Date_format $date, Date_time_format $date_time, Time_format $time, CommonSettings $common_settings)
151
    {
152
        try {
153
            /* fetch the values of system from system table */
154
            $systems = $system->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\System>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
155
            /* Fetch the values from Department table */
156
            $departments = $department->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Agent\Department>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
157
            /* Fetch the values from Timezones table */
158
            $timezones = $timezone->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Utility\Timezones>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
159
            /* Fetch status value of common settings */
160
            $common_setting = $common_settings->select('status')
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<App\Model\helpdes...ettings\CommonSettings>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
161
                    ->where('option_name', '=', 'user_set_ticket_status')
162
                    ->first();
163
            $send_otp = $common_settings->select('status')
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<App\Model\helpdes...ettings\CommonSettings>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
164
                    ->where('option_name', '=', 'send_otp')
165
                    ->first();
166
            $email_mandatory = $common_settings->select('status')
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<App\Model\helpdes...ettings\CommonSettings>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
167
                    ->where('option_name', '=', 'email_mandatory')
168
                    ->first();
169
            /* Direct to System Settings Page */
170
            return view('themes.default1.admin.helpdesk.settings.system', compact('systems', 'departments', 'timezones', 'time', 'date', 'date_time', 'common_setting', 'send_otp', 'email_mandatory'));
171
        } catch (Exception $e) {
172
            return redirect()->back()->with('fails', $e->getMessage());
173
        }
174
    }
175
176
    /**
177
     * Update the specified resource in storage.
178
     *
179
     * @param type int           $id
180
     * @param type System        $system
181
     * @param type SystemRequest $request
182
     *
183
     * @return type Response
184
     */
185
    public function postsystem($id, System $system, SystemRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
186
    {
187
        try {
188
            /* fetch the values of system request  */
189
            $systems = $system->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\System>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
190
            /* fill the values to coompany table */
191
            /* Check whether function success or not */
192
            $systems->fill($request->input())->save();
193
            $rtl = CommonSettings::where('option_name', '=', 'enable_rtl')->first();
194
            if ($request->enable_rtl != null) {
0 ignored issues
show
Documentation introduced by
The property enable_rtl does not exist on object<App\Http\Requests\helpdesk\SystemRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
195
                $rtl->option_value = 1;
196
            } else {
197
                $rtl->option_value = 0;
198
            }
199
            $rtl->save();
200
201
            $usts = CommonSettings::where('option_name', '=', 'user_set_ticket_status')->first();
202
            if ($usts->status != $request->user_set_ticket_status) {
0 ignored issues
show
Documentation introduced by
The property user_set_ticket_status does not exist on object<App\Http\Requests\helpdesk\SystemRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
203
                $usts->status = $request->user_set_ticket_status;
0 ignored issues
show
Bug introduced by
The property user_set_ticket_status does not seem to exist in App\Http\Requests\helpdesk\SystemRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
204
                $usts->save();
205
            }
206
            $sotp = CommonSettings::where('option_name', '=', 'send_otp')
0 ignored issues
show
Unused Code introduced by
$sotp is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
207
                    ->update(['status' => $request->send_otp]);
0 ignored issues
show
Documentation introduced by
The property send_otp does not exist on object<App\Http\Requests\helpdesk\SystemRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
208
            $email_mandatory = CommonSettings::where('option_name', '=', 'email_mandatory')
0 ignored issues
show
Unused Code introduced by
$email_mandatory is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
209
                    ->update(['status' => $request->email_mandatory]);
0 ignored issues
show
Documentation introduced by
The property email_mandatory does not exist on object<App\Http\Requests\helpdesk\SystemRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
210
211
            if ($request->has('itil')) {
212
                $itil = $request->input('itil');
213
                $sett = CommonSettings::firstOrCreate(['option_name'=>'itil']);
0 ignored issues
show
Bug introduced by
The method firstOrCreate() does not exist on App\Model\helpdesk\Settings\CommonSettings. Did you maybe mean create()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
214
                $sett->status = $itil;
215
                $sett->save();
216
            }
217
            /* redirect to Index page with Success Message */
218
            return redirect('getsystem')->with('success', Lang::get('lang.system_updated_successfully'));
219
        } catch (Exception $e) {
220
            /* redirect to Index page with Fails Message */
221
            return redirect('getsystem')->with('fails', Lang::get('lang.system_can_not_updated').'<br>'.$e->getMessage());
222
        }
223
    }
224
225
    /**
226
     * get the form for Ticket setting page.
227
     *
228
     * @param type Ticket     $ticket
229
     * @param type Sla_plan   $sla
230
     * @param type Help_topic $topic
231
     * @param type Priority   $priority
232
     *
233
     * @return type Response
234
     */
235
    public function getticket(Ticket $ticket, Sla_plan $sla, Help_topic $topic, Ticket_Priority $priority)
236
    {
237
        try {
238
            /* fetch the values of ticket from ticket table */
239
            $tickets = $ticket->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Ticket>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
240
            /* Fetch the values from SLA Plan table */
241
            $slas = $sla->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Manage\Sla_plan>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
242
            /* Fetch the values from Help_topic table */
243
            $topics = $topic->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Manage\Help_topic>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
244
            /* Direct to Ticket Settings Page */
245
            return view('themes.default1.admin.helpdesk.settings.ticket', compact('tickets', 'slas', 'topics', 'priority'));
246
        } catch (Exception $e) {
247
            return redirect()->back()->with('fails', $e->getMessage());
248
        }
249
    }
250
251
    /**
252
     * Update the specified Ticket in storage.
253
     *
254
     * @param type int     $id
255
     * @param type Ticket  $ticket
256
     * @param type Request $request
257
     *
258
     * @return type Response
259
     */
260 View Code Duplication
    public function postticket($id, Ticket $ticket, Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
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...
261
    {
262
        try {
263
            /* fetch the values of ticket request  */
264
            $tickets = $ticket->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Ticket>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
265
            /* fill the values to coompany table */
266
            $tickets->fill($request->except('captcha', 'claim_response', 'assigned_ticket', 'answered_ticket', 'agent_mask', 'html', 'client_update'))->save();
267
            /* insert checkbox to Database  */
268
            $tickets->captcha = $request->input('captcha');
269
            $tickets->claim_response = $request->input('claim_response');
270
            $tickets->assigned_ticket = $request->input('assigned_ticket');
271
            $tickets->answered_ticket = $request->input('answered_ticket');
272
            $tickets->agent_mask = $request->input('agent_mask');
273
            $tickets->html = $request->input('html');
274
            $tickets->client_update = $request->input('client_update');
275
            $tickets->collision_avoid = $request->input('collision_avoid');
276
            /* Check whether function success or not */
277
            $tickets->save();
278
            /* redirect to Index page with Success Message */
279
            return redirect('getticket')->with('success', Lang::get('lang.ticket_updated_successfully'));
280
        } catch (Exception $e) {
281
            /* redirect to Index page with Fails Message */
282
            return redirect('getticket')->with('fails', Lang::get('lang.ticket_can_not_updated').'<li>'.$e->getMessage().'</li>');
283
        }
284
    }
285
286
    /**
287
     * get the form for Email setting page.
288
     *
289
     * @param type Email    $email
290
     * @param type Template $template
291
     * @param type Emails   $email1
292
     *
293
     * @return type Response
294
     */
295
    public function getemail(Email $email, Template $template, Emails $email1)
296
    {
297
        try {
298
            /* fetch the values of email from Email table */
299
            $emails = $email->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Email>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
300
            /* Fetch the values from Template table */
301
            $templates = $template->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Email\Template>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
302
            /* Fetch the values from Emails table */
303
            $emails1 = $email1->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Email\Emails>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
304
            /* Direct to Email Settings Page */
305
            return view('themes.default1.admin.helpdesk.settings.email', compact('emails', 'templates', 'emails1'));
306
        } catch (Exception $e) {
307
            return redirect()->back()->with('fails', $e->getMessage());
308
        }
309
    }
310
311
    /**
312
     * Update the specified email setting in storage.
313
     *
314
     * @param type int          $id
315
     * @param type Email        $email
316
     * @param type EmailRequest $request
317
     *
318
     * @return type Response
319
     */
320 View Code Duplication
    public function postemail($id, Email $email, EmailRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
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...
321
    {
322
        try {
323
            /* fetch the values of email request  */
324
            $emails = $email->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Email>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
325
            /* fill the values to email table */
326
            $emails->fill($request->except('email_fetching', 'all_emails', 'email_collaborator', 'strip', 'attachment'))->save();
327
            /* insert checkboxes  to database */
328
            // $emails->email_fetching = $request->input('email_fetching');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
329
            // $emails->notification_cron = $request->input('notification_cron');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
330
            $emails->all_emails = $request->input('all_emails');
331
            $emails->email_collaborator = $request->input('email_collaborator');
332
            $emails->strip = $request->input('strip');
333
            $emails->attachment = $request->input('attachment');
334
            /* Check whether function success or not */
335
            $emails->save();
336
            /* redirect to Index page with Success Message */
337
            return redirect('getemail')->with('success', Lang::get('lang.email_updated_successfully'));
338
        } catch (Exception $e) {
339
            /* redirect to Index page with Fails Message */
340
            return redirect('getemail')->with('fails', Lang::get('lang.email_can_not_updated').'<li>'.$e->getMessage().'</li>');
341
        }
342
    }
343
344
    /**
345
     * get the form for cron job setting page.
346
     *
347
     * @param type Email    $email
348
     * @param type Template $template
349
     * @param type Emails   $email1
350
     *
351
     * @return type Response
352
     */
353
    public function getSchedular(Email $email, Template $template, Emails $email1, WorkflowClose $workflow)
354
    {
355
        // try {
356
        /* fetch the values of email from Email table */
357
        $emails = $email->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Email>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
358
        /* Fetch the values from Template table */
359
        $templates = $template->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Email\Template>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
360
        /* Fetch the values from Emails table */
361
        $emails1 = $email1->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\helpdesk\Email\Emails>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
362
363
        $workflow = $workflow->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Workflow\WorkflowClose>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
364
        $cron_path = base_path('artisan');
365
        $command = ":- <pre>***** php $cron_path schedule:run >> /dev/null 2>&1</pre>";
366
        $shared = ":- <pre>/usr/bin/php-cli -q  $cron_path schedule:run >> /dev/null 2>&1</pre>";
367
        $warn = '';
368
        $condition = new \App\Model\MailJob\Condition();
369
        $job = $condition->checkActiveJob();
0 ignored issues
show
Unused Code introduced by
$job is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
370
        $commands = [
371
            ''                   => 'Select',
372
            'everyMinute'        => 'Every Minute',
373
            'everyFiveMinutes'   => 'Every Five Minute',
374
            'everyTenMinutes'    => 'Every Ten Minute',
375
            'everyThirtyMinutes' => 'Every Thirty Minute',
376
            'hourly'             => 'Every Hour',
377
            'daily'              => 'Every Day',
378
            'dailyAt'            => 'Daily at',
379
            'weekly'             => 'Every Week',
380
            'monthly'            => 'Monthly',
381
            'yearly'             => 'Yearly',
382
        ];
383
        $followupcommands = [
384
            ''                   => 'Select',
385
            'everyMinute'        => 'Every Minute',
386
            'everyFiveMinutes'   => 'Every Five Minute',
387
            'everyTenMinutes'    => 'Every Ten Minute',
388
            'everyThirtyMinutes' => 'Every Thirty Minute',
389
            'hourly'             => 'Every Hour',
390
            'daily'              => 'Every Day',
391
            'weekly'             => 'Every Week',
392
            'monthly'            => 'Monthly',
393
            'yearly'             => 'Yearly',
394
        ];
395
        if (ini_get('register_argc_argv') == '') {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
396
            //$warn = "Please make 'register_argc_argv' flag as on. Or you can set all your job url in cron";
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
397
        }
398
399
        return view('themes.default1.admin.helpdesk.settings.cron.cron', compact('emails', 'templates', 'emails1', 'workflow', 'warn', 'command', 'commands', 'followupcommands', 'condition', 'shared'));
400
        // } catch {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
401
        // }
402
    }
403
404
    /**
405
     * Update the specified schedular in storage for cron job.
406
     *
407
     * @param type Email        $email
408
     * @param type EmailRequest $request
409
     *
410
     * @return type Response
411
     */
412
    public function postSchedular(Email $email, Template $template, Emails $email1, TaskRequest $request, WorkflowClose $workflow)
0 ignored issues
show
Unused Code introduced by
The parameter $template 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...
Unused Code introduced by
The parameter $email1 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...
413
    {
414
        try {
415
            /* fetch the values of email request  */
416
            $emails = $email->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Email>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
417
            if ($request->email_fetching) {
0 ignored issues
show
Documentation introduced by
The property email_fetching does not exist on object<App\Http\Requests...lpdesk\Job\TaskRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
418
                $emails->email_fetching = $request->email_fetching;
0 ignored issues
show
Bug introduced by
The property email_fetching does not seem to exist in App\Http\Requests\helpdesk\Job\TaskRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
419
            } else {
420
                $emails->email_fetching = 0;
421
            }
422
            if ($request->notification_cron) {
0 ignored issues
show
Documentation introduced by
The property notification_cron does not exist on object<App\Http\Requests...lpdesk\Job\TaskRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
423
                $emails->notification_cron = $request->notification_cron;
0 ignored issues
show
Bug introduced by
The property notification_cron does not seem to exist in App\Http\Requests\helpdesk\Job\TaskRequest.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
424
            } else {
425
                $emails->notification_cron = 0;
426
            }
427
            $emails->save();
428
            //workflow
429
            $work = $workflow->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Workflow\WorkflowClose>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
430
            if ($request->condition) {
0 ignored issues
show
Documentation introduced by
The property condition does not exist on object<App\Http\Requests...lpdesk\Job\TaskRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
431
                $work->condition = 1;
432
            } else {
433
                $work->condition = 0;
434
            }
435
            $work->save();
436
            $this->saveConditions();
437
            /* redirect to Index page with Success Message */
438
            return redirect('job-scheduler')->with('success', Lang::get('lang.job-scheduler-success'));
439
        } catch (Exception $e) {
440
            /* redirect to Index page with Fails Message */
441
            return redirect('job-scheduler')->with('fails', Lang::get('lang.job-scheduler-error').'<li>'.$e->getMessage().'</li>');
442
        }
443
    }
444
445
    /**
446
     * get the form for Responder setting page.
447
     *
448
     * @param type Responder $responder
449
     *
450
     * @return type Response
451
     */
452
    public function getresponder(Responder $responder)
453
    {
454
        try {
455
            /* fetch the values of responder from responder table */
456
            $responders = $responder->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Responder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
457
            /* Direct to Responder Settings Page */
458
            return view('themes.default1.admin.helpdesk.settings.responder', compact('responders'));
459
        } catch (Exception $e) {
460
            return redirect()->back()->with('fails', $e->getMessage());
461
        }
462
    }
463
464
    /**
465
     * Update the specified autoresponse in storage.
466
     *
467
     * @param type Responder $responder
468
     * @param type Request   $request
469
     *
470
     * @return type
471
     */
472 View Code Duplication
    public function postresponder(Responder $responder, Request $request)
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...
473
    {
474
        try {
475
            /* fetch the values of responder request  */
476
            $responders = $responder->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Responder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
477
            /* insert Checkbox value to DB */
478
            $responders->new_ticket = $request->input('new_ticket');
479
            $responders->agent_new_ticket = $request->input('agent_new_ticket');
480
            $responders->submitter = $request->input('submitter');
481
            $responders->participants = $request->input('participants');
482
            $responders->overlimit = $request->input('overlimit');
483
            /* fill the values to coompany table */
484
            /* Check whether function success or not */
485
            $responders->save();
486
            /* redirect to Index page with Success Message */
487
            return redirect('getresponder')->with('success', Lang::get('lang.auto_response_updated_successfully'));
488
        } catch (Exception $e) {
489
            /* redirect to Index page with Fails Message */
490
            return redirect('getresponder')->with('fails', Lang::get('lang.auto_response_can_not_updated').'<li>'.$e->getMessage().'</li>');
491
        }
492
    }
493
494
    /**
495
     * get the form for Alert setting page.
496
     *
497
     * @param type Alert $alert
498
     *
499
     * @return type Response
500
     */
501
    public function getalert(Alert $alert)
502
    {
503
        try {
504
            /* fetch the values of alert from alert table */
505
            $alerts = $alert->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Alert>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
506
            /* Direct to Alert Settings Page */
507
            return view('themes.default1.admin.helpdesk.settings.alert', compact('alerts'));
508
        } catch (Exception $e) {
509
            return redirect()->back()->with('fails', $e->getMessage());
510
        }
511
    }
512
513
    /**
514
     * Update the specified alert in storage.
515
     *
516
     * @param type         $id
517
     * @param type Alert   $alert
518
     * @param type Request $request
519
     *
520
     * @return type Response
521
     */
522 View Code Duplication
    public function postalert($id, Alert $alert, Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $id 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...
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...
523
    {
524
        try {
525
            /* fetch the values of alert request  */
526
            $alerts = $alert->whereId('1')->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Settings\Alert>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
527
            /* Insert Checkbox to DB */
528
            $alerts->assignment_status = $request->input('assignment_status');
529
            $alerts->ticket_status = $request->input('ticket_status');
530
            $alerts->overdue_department_member = $request->input('overdue_department_member');
531
            $alerts->sql_error = $request->input('sql_error');
532
            $alerts->excessive_failure = $request->input('excessive_failure');
533
            $alerts->overdue_status = $request->input('overdue_status');
534
            $alerts->overdue_assigned_agent = $request->input('overdue_assigned_agent');
535
            $alerts->overdue_department_manager = $request->input('overdue_department_manager');
536
            $alerts->internal_status = $request->input('internal_status');
537
            $alerts->internal_last_responder = $request->input('internal_last_responder');
538
            $alerts->internal_assigned_agent = $request->input('internal_assigned_agent');
539
            $alerts->internal_department_manager = $request->input('internal_department_manager');
540
            $alerts->assignment_assigned_agent = $request->input('assignment_assigned_agent');
541
            $alerts->assignment_team_leader = $request->input('assignment_team_leader');
542
            $alerts->assignment_team_member = $request->input('assignment_team_member');
543
            $alerts->system_error = $request->input('system_error');
544
            $alerts->transfer_department_member = $request->input('transfer_department_member');
545
            $alerts->transfer_department_manager = $request->input('transfer_department_manager');
546
            $alerts->transfer_assigned_agent = $request->input('transfer_assigned_agent');
547
            $alerts->transfer_status = $request->input('transfer_status');
548
            $alerts->message_organization_accmanager = $request->input('message_organization_accmanager');
549
            $alerts->message_department_manager = $request->input('message_department_manager');
550
            $alerts->message_assigned_agent = $request->input('message_assigned_agent');
551
            $alerts->message_last_responder = $request->input('message_last_responder');
552
            $alerts->message_status = $request->input('message_status');
553
            $alerts->ticket_organization_accmanager = $request->input('ticket_organization_accmanager');
554
            $alerts->ticket_department_manager = $request->input('ticket_department_manager');
555
            $alerts->ticket_department_member = $request->input('ticket_department_member');
556
            $alerts->ticket_admin_email = $request->input('ticket_admin_email');
557
558
            if ($request->input('system_error') == null) {
559
                $str = '%0%';
560
                $path = app_path('../config/app.php');
561
                $content = \File::get($path);
562
                $content = str_replace('%1%', $str, $content);
563
                \File::put($path, $content);
564
            } else {
565
                $str = '%1%';
566
                $path = app_path('../config/app.php');
567
                $content = \File::get($path);
568
                $content = str_replace('%0%', $str, $content);
569
                \File::put($path, $content);
570
            }
571
            /* fill the values to coompany table */
572
            /* Check whether function success or not */
573
            $alerts->save();
574
            /* redirect to Index page with Success Message */
575
            return redirect('getalert')->with('success', Lang::get('lang.alert_&_notices_updated_successfully'));
576
        } catch (Exception $e) {
577
            /* redirect to Index page with Fails Message */
578
            return redirect('getalert')->with('fails', Lang::get('lang.alert_&_notices_can_not_updated').'<li>'.$e->getMessage().'</li>');
579
        }
580
    }
581
582
    /**
583
     *  Generate Api key.
584
     *
585
     *  @return type json
586
     */
587
    public function generateApiKey()
588
    {
589
        $key = str_random(32);
590
591
        return $key;
592
    }
593
594
    /**
595
     * Main Settings Page.
596
     *
597
     * @return type view
598
     */
599
    public function settings()
600
    {
601
        return view('themes.default1.admin.helpdesk.setting');
602
    }
603
604
    /**
605
     * @param int $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
606
     * @param $compant instance of company table
607
     *
608
     * get the form for company setting page
609
     *
610
     * @return Response
611
     */
612 View Code Duplication
    public function getStatuses()
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...
613
    {
614
        try {
615
            /* fetch the values of company from company table */
616
            $statuss = \DB::table('ticket_status')->get();
617
            /* Direct to Company Settings Page */
618
            return view('themes.default1.admin.helpdesk.settings.status', compact('statuss'));
619
        } catch (Exception $e) {
620
            return redirect()->back()->with('fails', $e->getMessage());
621
        }
622
    }
623
624
    /**
625
     * @param int $id
626
     * @param $compant instance of company table
627
     *
628
     * get the form for company setting page
629
     *
630
     * @return Response
631
     */
632 View Code Duplication
    public function getEditStatuses($id)
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...
633
    {
634
        try {
635
            /* fetch the values of company from company table */
636
            $status = \DB::table('ticket_status')->where('id', '=', $id)->first();
637
            /* Direct to Company Settings Page */
638
            return view('themes.default1.admin.helpdesk.settings.status-edit', compact('status'));
639
        } catch (Exception $e) {
640
            return redirect()->back()->with('fails', $e->getMessage());
641
        }
642
    }
643
644
    /**
645
     * @param int $id
646
     * @param $compant instance of company table
647
     *
648
     * get the form for company setting page
649
     *
650
     * @return Response
651
     */
652 View Code Duplication
    public function editStatuses($id, StatusRequest $request)
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...
653
    {
654
        try {
655
            /* fetch the values of company from company table */
656
            $statuss = \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->first();
657
            $statuss->name = $request->input('name');
658
            $statuss->icon_class = $request->input('icon_class');
659
            $statuss->email_user = $request->input('email_user');
660
            $statuss->sort = $request->input('sort');
661
            $delete = $request->input('deleted');
662
            if ($delete == 'yes') {
663
                $statuss->state = 'delete';
664
            } else {
665
                $statuss->state = $request->input('state');
666
            }
667
            $statuss->sort = $request->input('sort');
668
            $statuss->save();
669
            /* Direct to Company Settings Page */
670
            return redirect()->back()->with('success', Lang::get('lang.status_has_been_updated_successfully'));
671
        } catch (Exception $e) {
672
            return redirect()->back()->with('fails', $e->getMessage());
673
        }
674
    }
675
676
    /**
677
     * create a status.
678
     *
679
     * @param \App\Model\helpdesk\Ticket\Ticket_Status  $statuss
680
     * @param \App\Http\Requests\helpdesk\StatusRequest $request
681
     *
682
     * @return type redirect
683
     */
684 View Code Duplication
    public function createStatuses(\App\Model\helpdesk\Ticket\Ticket_Status $statuss, StatusRequest $request)
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...
685
    {
686
        try {
687
            /* fetch the values of company from company table */
688
            $statuss->name = $request->input('name');
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
689
            $statuss->icon_class = $request->input('icon_class');
0 ignored issues
show
Documentation introduced by
The property icon_class does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
690
            $statuss->email_user = $request->input('email_user');
0 ignored issues
show
Documentation introduced by
The property email_user does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
691
            $statuss->sort = $request->input('sort');
0 ignored issues
show
Documentation introduced by
The property sort does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
692
            $delete = $request->input('delete');
693
            if ($delete == 'yes') {
694
                $statuss->state = 'deleted';
0 ignored issues
show
Documentation introduced by
The property state does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
695
            } else {
696
                $statuss->state = $request->input('state');
0 ignored issues
show
Documentation introduced by
The property state does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
697
            }
698
            $statuss->sort = $request->input('sort');
0 ignored issues
show
Documentation introduced by
The property sort does not exist on object<App\Model\helpdesk\Ticket\Ticket_Status>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
699
            $statuss->save();
700
            /* Direct to Company Settings Page */
701
            return redirect()->back()->with('success', Lang::get('lang.status_has_been_created_successfully'));
702
        } catch (Exception $ex) {
703
            return redirect()->back()->with('fails', $ex->getMessage());
704
        }
705
    }
706
707
    /**
708
     * delete a status.
709
     *
710
     * @param type $id
711
     *
712
     * @return type redirect
713
     */
714
    public function deleteStatuses($id)
715
    {
716
        try {
717 View Code Duplication
            if ($id > 5) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
718
                /* fetch the values of company from company table */
719
                \App\Model\helpdesk\Ticket\Ticket_Status::whereId($id)->delete();
720
                /* Direct to Company Settings Page */
721
                return redirect()->back()->with('success', Lang::get('lang.status_has_been_deleted'));
722
            } else {
723
                return redirect()->back()->with('failed', Lang::get('lang.you_cannot_delete_this_status'));
724
            }
725
        } catch (Exception $e) {
726
            return redirect()->back()->with('fails', $e->getMessage());
727
        }
728
    }
729
730
    /**
731
     * get the page of notification settings.
732
     *
733
     * @return type view
734
     */
735
    public function notificationSettings()
736
    {
737
        return view('themes.default1.admin.helpdesk.settings.notification');
738
    }
739
740
    /**
741
     * delete a notification.
742
     *
743
     * @return type redirect
744
     */
745 View Code Duplication
    public function deleteReadNoti()
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...
746
    {
747
        $markasread = UserNotification::where('is_read', '=', 1)->get();
748
        foreach ($markasread as $mark) {
749
            $mark->delete();
750
            \App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
751
        }
752
753
        return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_read_notifications'));
754
    }
755
756
    /**
757
     * delete a notification log.
758
     *
759
     * @return type redirect
760
     */
761
    public function deleteNotificationLog()
762
    {
763
        $days = Input::get('no_of_days');
764
        if ($days == null) {
765
            return redirect()->back()->with('fails', 'Please enter valid no of days');
766
        }
767
        $date = new DateTime();
768
        $date->modify($days.' day');
769
        $formatted_date = $date->format('Y-m-d H:i:s');
770
        $markasread = UserNotification::where('created_at', '<=', $formatted_date)->get();
771
        foreach ($markasread as $mark) {
772
            $mark->delete();
773
            \App\Model\helpdesk\Notification\Notification::whereId($mark->notification_id)->delete();
774
        }
775
776
        return redirect()->back()->with('success', Lang::get('lang.you_have_deleted_all_the_notification_records_since').$days.' days.');
777
    }
778
779
    /**
780
     *  To display the list of ratings in the system.
781
     *
782
     *  @return type View
783
     */
784
    public function RatingSettings()
785
    {
786
        try {
787
            $ratings = Rating::orderBy('display_order', 'asc')->get();
788
789
            return view('themes.default1.admin.helpdesk.settings.ratings', compact('ratings'));
790
        } catch (Exception $ex) {
791
            return redirect()->back()->with('fails', $ex->getMessage());
792
        }
793
    }
794
795
    /**
796
     * edit a rating.
797
     *
798
     * @param type $id
799
     *
800
     * @return type view
801
     */
802 View Code Duplication
    public function editRatingSettings($id)
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...
803
    {
804
        try {
805
            $rating = Rating::whereId($id)->first();
806
807
            return view('themes.default1.admin.helpdesk.settings.edit-ratings', compact('rating'));
808
        } catch (Exception $ex) {
809
            return redirect()->back()->with('fails', $ex->getMessage());
810
        }
811
    }
812
813
    /**
814
     *  To store rating data.
815
     *
816
     *  @return type Redirect
817
     */
818
    public function PostRatingSettings($id, Rating $ratings, RatingUpdateRequest $request)
819
    {
820
        try {
821
            $rating = $ratings->whereId($id)->first();
0 ignored issues
show
Documentation Bug introduced by
The method whereId does not exist on object<App\Model\helpdesk\Ratings\Rating>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
822
            $rating->name = $request->input('name');
823
            $rating->display_order = $request->input('display_order');
824
            $rating->allow_modification = $request->input('allow_modification');
825
            $rating->rating_scale = $request->input('rating_scale');
826
//            $rating->rating_area = $request->input('rating_area');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
827
            $rating->restrict = $request->input('restrict');
828
            $rating->save();
829
830
            return redirect()->back()->with('success', Lang::get('lang.ratings_updated_successfully'));
831
        } catch (Exception $ex) {
832
            return redirect()->back()->with('fails', $ex->getMessage());
833
        }
834
    }
835
836
    /**
837
     * get the create rating page.
838
     *
839
     * @return type redirect
840
     */
841
    public function createRating()
842
    {
843
        try {
844
            return view('themes.default1.admin.helpdesk.settings.create-ratings');
845
        } catch (Exception $ex) {
846
            return redirect('getratings')->with('fails', Lang::get('lang.ratings_can_not_be_created').'<li>'.$ex->getMessage().'</li>');
847
        }
848
    }
849
850
    /**
851
     * store a rating value.
852
     *
853
     * @param \App\Model\helpdesk\Ratings\Rating        $rating
854
     * @param \App\Model\helpdesk\Ratings\RatingRef     $ratingrefs
855
     * @param \App\Http\Requests\helpdesk\RatingRequest $request
856
     *
857
     * @return type redirect
858
     */
859
    public function storeRating(Rating $rating, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs, \App\Http\Requests\helpdesk\RatingRequest $request)
860
    {
861
        $rating->name = $request->input('name');
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
862
        $rating->display_order = $request->input('display_order');
0 ignored issues
show
Documentation introduced by
The property display_order does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
863
        $rating->allow_modification = $request->input('allow_modification');
0 ignored issues
show
Documentation introduced by
The property allow_modification does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
864
        $rating->rating_scale = $request->input('rating_scale');
0 ignored issues
show
Documentation introduced by
The property rating_scale does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
865
        $rating->rating_area = $request->input('rating_area');
0 ignored issues
show
Documentation introduced by
The property rating_area does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
866
        $rating->restrict = $request->input('restrict');
0 ignored issues
show
Documentation introduced by
The property restrict does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
867
        $rating->save();
868
        $ratingrefs->rating_id = $rating->id;
0 ignored issues
show
Documentation introduced by
The property rating_id does not exist on object<App\Model\helpdesk\Ratings\RatingRef>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property id does not exist on object<App\Model\helpdesk\Ratings\Rating>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
869
        $ratingrefs->save();
870
871
        return redirect()->back()->with('success', Lang::get('lang.successfully_created_this_rating'));
872
    }
873
874
    /**
875
     *  To delete a type of rating.
876
     *
877
     *  @return type Redirect
878
     */
879
    public function RatingDelete($slug, \App\Model\helpdesk\Ratings\RatingRef $ratingrefs)
880
    {
881
        $ratingrefs->where('rating_id', '=', $slug)->delete();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\Model\helpdesk\Ratings\RatingRef>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
882
        Rating::whereId($slug)->delete();
883
884
        return redirect()->back()->with('success', Lang::get('lang.rating_deleted_successfully'));
885
    }
886
887
    public function saveConditions()
888
    {
889
        if (\Input::get('fetching-commands') && \Input::get('notification-commands')) {
890
            $fetching_commands = \Input::get('fetching-commands');
891
            $fetching_dailyAt = \Input::get('fetching-dailyAt');
892
            $notification_commands = \Input::get('notification-commands');
893
            $notification_dailyAt = \Input::get('notification-dailyAt');
894
            $work_commands = \Input::get('work-commands');
895
            $workflow_dailyAt = \Input::get('workflow-dailyAt');
896
            $fetching_command = $this->getCommand($fetching_commands, $fetching_dailyAt);
897
            $notification_command = $this->getCommand($notification_commands, $notification_dailyAt);
898
            $work_command = $this->getCommand($work_commands, $workflow_dailyAt);
899
            $jobs = ['fetching'=>$fetching_command, 'notification'=>$notification_command, 'work'=>$work_command];
900
            $this->storeCommand($jobs);
901
        }
902
    }
903
904
    public function getCommand($command, $daily_at)
905
    {
906
        if ($command == 'dailyAt') {
907
            $command = "dailyAt,$daily_at";
908
        }
909
910
        return $command;
911
    }
912
913
    public function storeCommand($array = [])
914
    {
915
        $command = new \App\Model\MailJob\Condition();
916
        $commands = $command->get();
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<App\Model\MailJob\Condition>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
917
        if ($commands->count() > 0) {
918
            foreach ($commands as $condition) {
919
                $condition->delete();
920
            }
921
        }
922
        if (count($array) > 0) {
923
            foreach ($array as $key=>$save) {
924
                $command->create([
925
                    'job'  => $key,
926
                    'value'=> $save,
927
                ]);
928
            }
929
        }
930
    }
931
932
    public function getTicketNumber(Request $request)
933
    {
934
        $this->validate($request, [
935
            'format' => ['required', 'regex:/^(?=.*[$|-|#]).+$/'],
936
            'type'   => 'required',
937
        ]);
938
939
        $format = $request->input('format');
940
        $type = $request->input('type');
941
        $number = $this->switchNumber($format, $type);
942
943
        return $number;
944
    }
945
946
    public function switchNumber($format, $type)
947
    {
948
        switch ($type) {
949
            case 'random':
950
                return $this->createRandomNumber($format);
951
            case 'sequence':
952
                return $this->createSequencialNumber($format);
953
        }
954
    }
955
956 View Code Duplication
    public function createRandomNumber($format)
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...
957
    {
958
        $number = '';
959
        $array = str_split($format);
960
        for ($i = 0; $i < count($array); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
961
            if ($array[$i] === '$') {
962
                $number .= $this->getRandomAlphebet();
963
            }
964
            if ($array[$i] === '#') {
965
                $number .= rand(0, 9);
966
            }
967
            if ($array[$i] !== '$' && $array[$i] !== '#') {
968
                $number .= $array[$i];
969
            }
970
        }
971
972
        return $number;
973
    }
974
975 View Code Duplication
    public function createSequencialNumber($format)
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...
976
    {
977
        $number = '';
978
        $array_format = str_split($format);
979
        $count = count($array_format);
980
        for ($i = 0; $i < $count; $i++) {
981
            //dd($sub);
982
            if ($array_format[$i] === '$') {
983
                $number .= 'A';
984
            }
985
986
            if ($array_format[$i] === '#') {
987
                $number .= '0';
988
            }
989
990
            if ($array_format[$i] !== '$' && $array_format[$i] !== '#') {
991
                $number .= $array_format[$i];
992
            }
993
        }
994
995
        return $number;
996
        //return $this->nthTicketNumber($number);
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% 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...
997
    }
998
999
    public function checkCurrentFormat($current, $format)
1000
    {
1001
        $check = true;
1002
        $array_current = str_split($current);
1003
        $array_format = str_split($format);
1004
        $count_current = count($array_current);
1005
        $count_format = count($array_format);
1006
        if ($count_current === $count_format) {
1007
            return false;
1008
        }
1009
        for ($i = 0; $i < $count_current; $i++) {
1010
            if ($array_current[$i] !== $array_format[$i]) {
1011
                return false;
1012
            }
1013
        }
1014
1015
        return $check;
1016
    }
1017
1018
    public function nthTicketNumber($current, $type, $format, $force = false)
1019
    {
1020
        $check = $this->checkCurrentFormat($current, $format);
1021
        if ($check === false && $force === false) {
1022
            $current = $this->createSequencialNumber($format);
1023
        }
1024
        if ($type === 'sequence') {
1025
            $pos_first = stripos($current, '-');
1026
            $pos_last = strpos($current, '-', $pos_first + 1);
1027
            $current = str_replace('-', '', $current);
1028
            $number = ++$current;
1029
            if ($pos_first) {
1030
                $number = substr_replace($number, '-', $pos_first, 0);
1031
            }
1032
            if ($pos_last) {
1033
                $number = substr_replace($number, '-', $pos_last, 0);
1034
            }
1035
        }
1036
        if ($type === 'random') {
1037
            $number = $this->createRandomNumber($format);
1038
        }
1039
1040
        return $number;
0 ignored issues
show
Bug introduced by
The variable $number does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
1041
    }
1042
1043
    public function getRandomAlphebet()
1044
    {
1045
        $alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
1046
        $shuffled = str_shuffle($alpha);
1047
        $shuffled_array = str_split($shuffled);
1048
        $char = $shuffled_array[0];
1049
1050
        return $char;
1051
    }
1052
}
1053