Passed
Branch master (93b6ae)
by refat
12:48
created

isExtesntionAllowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
use System\Application;
4
use System\File;
5
6
if (!function_exists('pre')) {
7
  function pre($var)
8
  {
9
    echo '<pre>';
10
    print_r($var);
11
    echo '</pre>';
12
  }
13
}
14
15
if (!function_exists('array_get')) {
16
  function array_get($array, $key, $default = null)
17
  {
18
    return ($array[$key] || $array[$key] == '0') ? $array[$key] : $default;
19
  }
20
}
21
22
if (!function_exists('app')) {
23
  function app()
24
  {
25
    return Application::getInstance(new File(__DIR__));
26
  }
27
}
28
29
if (!function_exists('_e')) {
30
  function _e($value)
31
  {
32
    $value = trim($value);
33
    $value = preg_replace('# {2,}#', ' ', $value);
34
    $value = htmlspecialchars($value);
35
    return $value;
36
  }
37
}
38
39
if (!function_exists('getLastParameter')) {
40
  function getLastParameter($index)
41
  {
42
    $array = explode('/', $index);
43
    return end($array);
44
  }
45
}
46
47
if (!function_exists('userId')) {
48
  function userId()
49
  {
50
    return getLastParameter(app()->request->baseUrl());
51
  }
52
}
53
54
if (!function_exists('url')) {
55
  function url($path)
56
  {
57
    return app()->url->link($path);
58
  }
59
}
60
61
if (!function_exists('assets')) {
62
  function assets($path = null)
63
  {
64
    return app()->url->link('public' . DS . $path);
65
  }
66
}
67
68
if (!function_exists('remove_space')) {
69
  function remove_space($str)
70
  {
71
    return str_replace(' ', '-', $str);
72
  }
73
}
74
75
if (!function_exists('remove_dash')) {
76
  function remove_dash($str)
77
  {
78
    return str_replace('-', ' ', $str);
79
  }
80
}
81
82
if (!function_exists('text_char_limit')) {
83
  function text_char_limit($text, $limit)
84
  {
85
    if (strlen($text) > $limit) {
86
      return substr($text, 0, $limit) . '...';
87
    }
88
  }
89
}
90
91
if (!function_exists('array_equal')) {
92
  function array_equal($a, $b)
93
  {
94
    return (
95
      is_array($a)
96
      && is_array($b)
97
      && count($a) == count($b)
98
      && array_diff($a, $b) === array_diff($b, $a)
99
    );
100
  }
101
}
102
103
if (!function_exists('isExtesntionAllowed')) {
104
  function isExtesntionAllowed($key, $extension)
105
  {
106
    $allowExtesntions = app()->file->call('config/uploads.php')[$key];
107
108
    return in_array($extension, $allowExtesntions);
109
  }
110
}
111
112
if (!function_exists('isImage')) {
113
  function isImage($minetype)
114
  {
115
    return strpos($minetype, "image/") === 0;
116
  }
117
}
118
119
if (!function_exists('notFoundPage')) {
120
121
 function notFoundPage()
122
  {
123
    $notfound = 'Website\Notfound';
124
125
    if (app()->request->isRequestToAdminManagement()) {
126
127
      $notfound = 'Admin\Notfound';
128
    }
129
130
    return (string) app()->load->action($notfound, 'index', []);
131
  }
132
}
133
134