1 | <?php |
||
2 | if(! function_exists("dd")) { |
||
3 | /** |
||
4 | * Little helper called dump and die |
||
5 | * @param $val |
||
6 | */ |
||
7 | function dd($val) { |
||
8 | \app\framework\Component\VarDumper\VarDumper::dump($val);die; |
||
0 ignored issues
–
show
The type
app\framework\Component\VarDumper\VarDumper was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
9 | } |
||
10 | } |
||
11 | |||
12 | if(! function_exists("pathTo")) { |
||
13 | /** |
||
14 | * Easy function to get the path to the project + if you want an directory in it. |
||
15 | * |
||
16 | * @param null $path |
||
0 ignored issues
–
show
|
|||
17 | * @return bool|string |
||
18 | */ |
||
19 | function pathTo($path = null) { |
||
20 | return realpath(dirname(__FILE__)."/../".$path); |
||
21 | } |
||
22 | } |
||
23 | |||
24 | if(! function_exists("view")) { |
||
25 | /** |
||
26 | * Get the evaluated view contents for the given view. |
||
27 | * |
||
28 | * @param string $view Name of template file. |
||
29 | * @param array $data Data to set values in template file |
||
30 | * @return \app\framework\Component\View\View|string |
||
31 | */ |
||
32 | function view($view = null, $data = []) { |
||
33 | $data['auth'] = new \app\framework\Component\Auth\Auth; |
||
34 | $View = new \app\framework\Component\View\View($view, $data); |
||
35 | return $View->render(); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | if(! function_exists("app")) { |
||
40 | /** |
||
41 | * Used to easily call Methods from classes without manually set |
||
42 | * locally Instances of them. |
||
43 | * |
||
44 | * @param string $classMethod The class name(if in \app\custom\ namespace) or the "namespace+className@methodToCall" |
||
45 | * @param array $param To declare what parameter shall be passed to the method |
||
46 | * @return mixed |
||
47 | */ |
||
48 | function app($classMethod, $param = []) { |
||
49 | return $GLOBALS["App"]->call($classMethod, $param); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | if(! function_exists("url")) { |
||
54 | /** |
||
55 | * Returns UrlObject with current url |
||
56 | * |
||
57 | * @return \app\framework\Component\StdLib\StdObject\UrlObject\UrlObject |
||
58 | */ |
||
59 | function url() { |
||
60 | return new \app\framework\Component\StdLib\StdObject\UrlObject\UrlObject($_SERVER['HTTP_HOST']); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | if(! function_exists("getStringBetween")) { |
||
65 | /** |
||
66 | * This is a handy little function to strip out a string between |
||
67 | * two specified pieces of text. This could be used to parse |
||
68 | * XML text, bbCode, or any other delimited code/text for that matter. |
||
69 | * |
||
70 | * @param $string |
||
71 | * @param $start |
||
72 | * @param $end |
||
73 | * @return bool|string |
||
74 | */ |
||
75 | function getStringBetween($string, $start, $end) { |
||
76 | $string = ' ' . $string; |
||
77 | $ini = strpos($string, $start); |
||
78 | if ($ini == 0) return ''; |
||
79 | $ini += strlen($start); |
||
80 | $len = strpos($string, $end, $ini) - $ini; |
||
81 | return substr($string, $ini, $len); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | if(! function_exists("handle")) { |
||
86 | function handle( $e) { |
||
87 | \app\framework\Component\Exception\Handler::getInstance()->handler($e); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | if(! function_exists("arr")) { |
||
92 | /** |
||
93 | * Create an ArrayObject from array |
||
94 | * |
||
95 | * @param array $arr |
||
96 | * @return \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject |
||
97 | */ |
||
98 | function arr(array $arr = []) { |
||
99 | return new \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject($arr); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | if(! function_exists("str")) { |
||
104 | function str($str) { |
||
105 | return new \app\framework\Component\StdLib\StdObject\StringObject\StringObject($str); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | if(! function_exists("encrypt")) { |
||
110 | /** |
||
111 | * Encrypt the given value. |
||
112 | * |
||
113 | * @param mixed $value |
||
114 | * @param bool $serialize |
||
115 | * @throws Exception |
||
116 | * @return string |
||
117 | */ |
||
118 | function encrypt($value, $serialize = true) { |
||
119 | $Encryptor = new \app\framework\Component\Encryption\Encrypter( |
||
120 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
||
121 | ); |
||
122 | |||
123 | return $Encryptor->encrypt($value, $serialize ); |
||
124 | } |
||
125 | } |
||
126 | |||
127 | if(! function_exists("decrypt")) { |
||
128 | /** |
||
129 | * Decrypt the given value. |
||
130 | * |
||
131 | * @param string $value |
||
132 | * @param bool $unserialize |
||
133 | * @throws Exception |
||
134 | * @return mixed |
||
135 | */ |
||
136 | function decrypt($value, $unserialize = true) { |
||
137 | $Encryptor = new \app\framework\Component\Encryption\Encrypter( |
||
138 | \app\framework\Component\Config\Config::getInstance()->get("CrypKey") |
||
139 | ); |
||
140 | |||
141 | return $Encryptor->decrypt($value, $unserialize ); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | if(! function_exists("version")) { |
||
146 | /** |
||
147 | * @return string version as written in config/app.php |
||
148 | */ |
||
149 | function version() { |
||
150 | return \app\framework\Component\Config\Config::getInstance()->get("version", "app"); |
||
0 ignored issues
–
show
The expression
return app\framework\Com...->get('version', 'app') could also return false which is incompatible with the documented return type string . Did you maybe forget to handle an error condition?
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled. ![]() |
|||
151 | } |
||
152 | } |
||
153 | |||
154 | if(! function_exists("isDebug")) { |
||
155 | function isDebug() { |
||
156 | return \app\framework\Component\Config\Config::getInstance()->get("debug", "app"); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | if(! function_exists("class_basename")) { |
||
161 | /** |
||
162 | * Get the class "basename" of the given object / class. |
||
163 | * |
||
164 | * @param string|object $class |
||
165 | * @return string |
||
166 | */ |
||
167 | function class_basename($class) |
||
168 | { |
||
169 | $class = is_object($class) ? get_class($class) : $class; |
||
170 | return basename(str_replace('\\', '/', $class)); |
||
171 | } |
||
172 | } |
||
173 | |||
174 | if (! function_exists("get_connection_log")) |
||
175 | { |
||
176 | /** |
||
177 | * returns query log from Connection as array |
||
178 | * |
||
179 | * @return array |
||
180 | * @throws \app\framework\Component\Database\Connection\ConnectionNotConfiguredException |
||
181 | */ |
||
182 | function get_connection_log() |
||
183 | { |
||
184 | return \app\framework\Component\Database\Connection\ConnectionFactory::getInstance()->get()->getQueryLog(); |
||
185 | } |
||
186 | } |
||
187 | |||
188 | if (! function_exists("datetime")) { |
||
189 | /** |
||
190 | * @param string $time |
||
191 | * @param null $timezone |
||
0 ignored issues
–
show
|
|||
192 | * @return \app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject |
||
193 | */ |
||
194 | function datetime($time = "now", $timezone = null) |
||
195 | { |
||
196 | return new \app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject($time, $timezone); |
||
197 | } |
||
198 | } |
||
199 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.