This repository was archived by the owner on Jul 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathUtils.php
More file actions
83 lines (75 loc) · 1.82 KB
/
Utils.php
File metadata and controls
83 lines (75 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace Sober\Controller;
class Utils
{
/**
* Is File PHP
*
* Determine if the file is a PHP file
* @return boolean
*/
public static function isFilePhp($filename)
{
return (in_array(pathinfo($filename, PATHINFO_EXTENSION), ['php']));
}
/**
* Does File Contain
*
* Determine if the file contains a string
* @return boolean
*/
public static function doesFileContain($filename, $str)
{
return strpos(file_get_contents($filename), $str) !== false;
}
/**
* Is Array Indexed
*
* Determine if the array is indexed
* @return boolean
*/
public static function isArrayIndexed(array $array)
{
return array_keys($array) === range(0, count($array) - 1);
}
/**
* Does String Contain Markup
*
* Determine if the string contains markup
* @return boolean
*/
public static function doesStringContainMarkup($str)
{
return (is_string($str) && $str !== strip_tags($str));
}
/**
* Convert To Snake Case
*
* Convert camel case to snake case for data variables
* @return string
*/
public static function convertToSnakeCase($str)
{
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $str));
}
/**
* Convert To Kebab Case
*
* Convert camel case to kebab case for templates
* @return string
*/
public static function convertToKebabCase($str)
{
return strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', $str));
}
/**
* Convert To Snake Case
*
* Converts kebab case to snake case for data variables
* @return string
*/
public static function convertKebabCaseToSnakeCase($str)
{
return strtolower(str_replace('-', '_', $str));
}
}