Skip to content

Commit ce0a817

Browse files
PHPCBF: auto-fix coding standards (PHP )
1 parent b52efa7 commit ce0a817

2 files changed

Lines changed: 64 additions & 60 deletions

File tree

src/ENV.php

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,38 @@
22

33
namespace JiJiHoHoCoCo\PHPENV;
44

5-
class ENV{
6-
7-
private static $env , $comma ;
8-
private static $dataset=[];
9-
10-
public static function set(string $filePath){
11-
if(is_readable($filePath)){
12-
self::$comma=rand();
13-
self::$env=implode(self::$comma,file($filePath) );
14-
}else{
15-
throw new Exception($filePath . ' is not exist', 1);
16-
}
17-
}
18-
19-
public static function get(){
20-
return self::$env;
21-
}
22-
23-
public static function getComma(){
24-
return self::$comma;
25-
}
26-
27-
public static function setDataset(string $key,$data){
28-
self::$dataset[$key]=$data;
29-
}
30-
31-
public static function getDataset(){
32-
return self::$dataset;
33-
}
34-
}
5+
class ENV
6+
{
7+
private static $env , $comma ;
8+
private static $dataset = [];
9+
10+
public static function set(string $filePath)
11+
{
12+
if (is_readable($filePath)) {
13+
self::$comma = rand();
14+
self::$env = implode(self::$comma, file($filePath));
15+
} else {
16+
throw new Exception($filePath . ' is not exist', 1);
17+
}
18+
}
19+
20+
public static function get()
21+
{
22+
return self::$env;
23+
}
24+
25+
public static function getComma()
26+
{
27+
return self::$comma;
28+
}
29+
30+
public static function setDataset(string $key, $data)
31+
{
32+
self::$dataset[$key] = $data;
33+
}
34+
35+
public static function getDataset()
36+
{
37+
return self::$dataset;
38+
}
39+
}

src/helpers.php

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@
22

33
use JiJiHoHoCoCo\PHPENV\ENV;
44

5-
if(!function_exists('getStringBetween')){
6-
function getStringBetween (string $str,string $from,string $to) : string {
5+
if (!function_exists('getStringBetween')) {
6+
function getStringBetween(string $str, string $from, string $to): string
7+
{
78

8-
$string = substr($str, strpos($str, $from) + strlen($from));
9+
$string = substr($str, strpos($str, $from) + strlen($from));
910

10-
if (strstr ($string,$to,TRUE) != FALSE) {
11+
if (strstr($string, $to, true) != false) {
12+
$string = strstr($string, $to, true);
13+
}
1114

12-
$string = strstr ($string,$to,TRUE);
13-
14-
}
15-
16-
return $string;
17-
18-
}
15+
return $string;
16+
}
1917
}
2018

21-
if(!function_exists('gete')){
22-
function gete(string $data){
23-
$previousData=$data;
24-
$dataset=ENV::getDataset();
25-
if(isset($dataset[$data])){
26-
return preg_replace('/\s+/', '',$dataset[$data]);
27-
}else{
28-
$data=$data.'=';
29-
$env=ENV::get();
30-
$comma=ENV::getComma();
31-
if($env==NULL){
32-
throw new \Exception("Please set the file path firstly", 1);
33-
}
34-
$getData=strpos($env,$data)!==FALSE ? getStringBetween($env,$data,$comma) : NULL;
35-
ENV::setDataset($previousData,$getData);
36-
return preg_replace('/\s+/', '',$getData);
37-
}
38-
}
39-
}
19+
if (!function_exists('gete')) {
20+
function gete(string $data)
21+
{
22+
$previousData = $data;
23+
$dataset = ENV::getDataset();
24+
if (isset($dataset[$data])) {
25+
return preg_replace('/\s+/', '', $dataset[$data]);
26+
} else {
27+
$data = $data . '=';
28+
$env = ENV::get();
29+
$comma = ENV::getComma();
30+
if ($env == null) {
31+
throw new \Exception("Please set the file path firstly", 1);
32+
}
33+
$getData = strpos($env, $data) !== false ? getStringBetween($env, $data, $comma) : null;
34+
ENV::setDataset($previousData, $getData);
35+
return preg_replace('/\s+/', '', $getData);
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)