This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace App\Helper; |
||
4 | |||
5 | use App\Model\helpdesk\Agent\Department; |
||
6 | use App\Model\helpdesk\Agent\Groups; |
||
7 | use App\Model\helpdesk\Ticket\Ticket_Status; |
||
8 | use App\Model\helpdesk\Ticket\TicketStatusType; |
||
9 | |||
10 | /** |
||
11 | *------------------------------------------------------------------ |
||
12 | * Class Finder |
||
13 | *------------------------------------------------------------------ |
||
14 | * Description: This class is used for defining some common functions |
||
15 | * used in the project. |
||
16 | * |
||
17 | * @author <Ladybird Web Solution> |
||
18 | */ |
||
19 | class Finder |
||
20 | { |
||
21 | /** |
||
22 | * DEPARTMENT |
||
23 | * This function is used for returning department name with respect to id. |
||
24 | * |
||
25 | * @param $id type int |
||
26 | * @param $custom type array/null |
||
27 | * |
||
28 | * @return type string |
||
29 | */ |
||
30 | View Code Duplication | public static function department($id, $custom = null) |
|
0 ignored issues
–
show
|
|||
31 | { |
||
32 | if ($custom == null) { |
||
33 | $department = Department::whereId($id)->select(['name']); |
||
34 | } elseif (isset($custom)) { |
||
35 | $department = Department::whereId($id)->select($custom); |
||
36 | } |
||
37 | |||
38 | return $department->first()->name; |
||
0 ignored issues
–
show
The variable
$department 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
![]() |
|||
39 | } |
||
40 | |||
41 | /** |
||
42 | * GROUP |
||
43 | * This function is used for returning group name with respect to id. |
||
44 | * |
||
45 | * @param $id type int |
||
46 | * @param $custom type array/null |
||
47 | * |
||
48 | * @return type string |
||
49 | */ |
||
50 | View Code Duplication | public static function group($id, $custom = null) |
|
0 ignored issues
–
show
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. ![]() |
|||
51 | { |
||
52 | if ($custom == null) { |
||
53 | $group = Groups::whereId($id)->select(['name']); |
||
54 | } elseif (isset($custom)) { |
||
55 | $group = Groups::whereId($id)->select($custom); |
||
56 | } |
||
57 | |||
58 | return $group->first()->name; |
||
0 ignored issues
–
show
The variable
$group 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
![]() |
|||
59 | } |
||
60 | |||
61 | /** |
||
62 | * STATUS TYPE |
||
63 | * This function is used for returning status type name with respect to id. |
||
64 | * |
||
65 | * @param $id type int |
||
66 | * @param $custom type array/null |
||
67 | * |
||
68 | * @return type string |
||
69 | */ |
||
70 | View Code Duplication | public static function statusType($id, $custom = null) |
|
0 ignored issues
–
show
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. ![]() |
|||
71 | { |
||
72 | if ($custom == null) { |
||
73 | $status_type = TicketStatusType::whereId($id)->select(['name']); |
||
74 | } elseif (isset($custom)) { |
||
75 | $status_type = TicketStatusType::whereId($id)->select($custom); |
||
76 | } |
||
77 | |||
78 | return $status_type->first()->name; |
||
0 ignored issues
–
show
The variable
$status_type 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
![]() |
|||
79 | } |
||
80 | |||
81 | /** |
||
82 | * STATUS |
||
83 | * This function is used for returning status name with respect to id. |
||
84 | * |
||
85 | * @param $id type int |
||
86 | * @param $custom type array/null |
||
87 | * |
||
88 | * @return type string |
||
89 | */ |
||
90 | View Code Duplication | public static function status($id, $custom = null) |
|
0 ignored issues
–
show
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. ![]() |
|||
91 | { |
||
92 | if ($custom == null) { |
||
93 | $status = Ticket_Status::whereId($id)->first(); |
||
94 | } elseif (isset($custom)) { |
||
95 | $status = Ticket_Status::whereId($id)->select($custom); |
||
96 | } |
||
97 | |||
98 | return $status; |
||
0 ignored issues
–
show
The variable
$status 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
![]() |
|||
99 | } |
||
100 | |||
101 | /** |
||
102 | * USER ROLES IN A GROUP FOR STATUS LIST |
||
103 | * This function is used to return roles of users from a given value. |
||
104 | * If the value is 1 the response is client |
||
105 | * If the value is 2 the response is agent |
||
106 | * If the value is 4 the response is admin |
||
107 | * If the value is 1+2 = 3 the response is client, agent |
||
108 | * If the value is 1+4 = 5 the response is client, admin |
||
109 | * If the value is 2+4 = 6 the response is agent, admin |
||
110 | * If the value is 1+2+4 = 7 the response is client, agent, admin. |
||
111 | * |
||
112 | * @param $id type int |
||
113 | * |
||
114 | * @return type string |
||
115 | */ |
||
116 | public static function rolesGroup($id) |
||
117 | { |
||
118 | switch ($id) { |
||
119 | case null: |
||
120 | return \Lang::get('lang.none'); |
||
121 | case 1: |
||
122 | return 'Client'; |
||
0 ignored issues
–
show
The return type of
return 'Client'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
123 | case 2: |
||
124 | return 'Agent'; |
||
0 ignored issues
–
show
The return type of
return 'Agent'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
125 | case 4: |
||
126 | return 'Admin'; |
||
0 ignored issues
–
show
The return type of
return 'Admin'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
127 | case 3: |
||
128 | return 'Client,Agent'; |
||
0 ignored issues
–
show
The return type of
return 'Client,Agent'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
129 | case 5: |
||
130 | return 'Client,Admin'; |
||
0 ignored issues
–
show
The return type of
return 'Client,Admin'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
131 | case 6: |
||
132 | return 'Agent,Admin'; |
||
0 ignored issues
–
show
The return type of
return 'Agent,Admin'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
133 | case 7: |
||
134 | return 'Client,Agent,Admin'; |
||
0 ignored issues
–
show
The return type of
return 'Client,Agent,Admin'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
135 | default: |
||
136 | return 'Undefined!'; |
||
0 ignored issues
–
show
The return type of
return 'Undefined!'; (string ) is incompatible with the return type documented by App\Helper\Finder::rolesGroup of type App\Helper\type .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
137 | } |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * ANY TYPE STATUS |
||
142 | * This function is used to return the set of status which are of any type passed in the param. |
||
143 | * |
||
144 | * @param type $id |
||
145 | * |
||
146 | * @return type array |
||
147 | */ |
||
148 | public static function anyTypeStatus($id) |
||
149 | { |
||
150 | $status_group = Ticket_Status::where('purpose_of_status', '=', $id)->select(['id'])->get(); |
||
151 | foreach ($status_group as $status) { |
||
152 | $status_group2[] = $status->id; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$status_group2 was never initialized. Although not strictly required by PHP, it is generally a good practice to add $status_group2 = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
153 | } |
||
154 | |||
155 | return $status_group2; |
||
0 ignored issues
–
show
The variable
$status_group2 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
![]() |
|||
156 | } |
||
157 | |||
158 | /** |
||
159 | * RETURNS ALL STATUS |
||
160 | * This function is used to return all the status given in the system. |
||
161 | * |
||
162 | * @return type array |
||
163 | */ |
||
164 | public static function getAllStatus() |
||
165 | { |
||
166 | $status = Ticket_Status::where('purpose_of_status', '!=', 3)->orwhere('purpose_of_status', '!=', 4)->get(); |
||
167 | |||
168 | return $status; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * VARIABLE REPLACEMENT |
||
173 | * This function is used to replace the replaceable variables form a given content for templates. |
||
174 | */ |
||
175 | public static function replaceTemplateVariables($variables, $data, $contents) |
||
176 | { |
||
177 | View Code Duplication | foreach ($variables as $key => $variable) { |
|
0 ignored issues
–
show
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. ![]() |
|||
178 | $messagebody = str_replace($variables[$key], $data[$key], $contents); |
||
179 | $contents = $messagebody; |
||
180 | } |
||
181 | |||
182 | return $contents; |
||
183 | } |
||
184 | } |
||
185 |
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.