Passed
Push — master ( 8305c3...b887ac )
by refat
05:04 queued 01:25
created

array_equal()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
c 2
b 0
f 0
nc 4
nop 2
dl 0
loc 7
rs 10
1
<?php
2
3
use System\Application;
4
5
if (!function_exists('pre')) {
6
  function pre($var)
7
  {
8
    echo '<pre>';
9
    print_r($var);
10
    echo '</pre>';
11
  }
12
}
13
14
if (!function_exists('array_get')) {
15
  function array_get($array, $key, $default = null)
16
  {
17
    return $array[$key] ?: $default;
18
  }
19
}
20
21
if (!function_exists('app')) {
22
  function app()
23
  {
24
    return Application::getInstance();
25
  }
26
}
27
28
if (!function_exists('_e')) {
29
  function _e($value)
30
  {
31
    return htmlspecialchars($value);
32
  }
33
}
34
35
if (!function_exists('getLastIndex')) {
36
  function getLastIndex($index)
37
  {
38
    $array = explode('\\', $index);
39
    return end($array);
40
  }
41
}
42
43
if (!function_exists('url')) {
44
  function url($path)
45
  {
46
    $app = Application::getInstance();
47
    return $app->url->link($path);
48
  }
49
}
50
51
if (!function_exists('assets')) {
52
  function assets($path)
53
  {
54
    $app = Application::getInstance();
55
    return $app->url->link('public' . DS . $path);
56
  }
57
}
58
59
if (!function_exists('remove_space')) {
60
  function remove_space($str)
61
  {
62
    return str_replace(' ', '-', $str);
63
  }
64
}
65
66
if (!function_exists('remove_dash')) {
67
  function remove_dash($str)
68
  {
69
    return str_replace('-', ' ', $str);
70
  }
71
}
72
73
if (!function_exists('text_char_limit')) {
74
  function text_char_limit($text, $limit)
75
  {
76
    if (strlen($text) > $limit) {
77
      return substr($text, 0, $limit) . '...';
78
    }
79
  }
80
}
81
82
if (!function_exists('array_equal')) {
83
  function array_equal($a, $b)
84
  {
85
    return (
86
      is_array($a)
87
      && is_array($b)
88
      && count($a) == count($b)
89
      && array_diff($a, $b) === array_diff($b, $a)
90
    );
91
  }
92
}
93
94
if (!function_exists('redirect_after')) {
95
  function redirect_after($num)
96
  {
97
    $app = Application::getInstance();
98
    $app->url->redirectTo('/', $num);
99
  }
100
}