Skip to content

Commit 7e2dc88

Browse files
committed
implement StrUtility facade class
1 parent 3cb4d56 commit 7e2dc88

File tree

4 files changed

+132
-83
lines changed

4 files changed

+132
-83
lines changed

src/Facade/Facade.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* @Package: some useful php string utility methods
5+
* @Class : Facade
6+
* @Author : Nima jahan bakhshian / dvlpr1996 <nimajahanbakhshian@gmail.com>
7+
* @URL : https://github.com/dvlpr1996
8+
* @License: MIT License Copyright (c) 2022 (until present) Nima jahan bakhshian
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace PhpStringHelpers\Facade;
14+
15+
use RuntimeException;
16+
17+
class Facade
18+
{
19+
protected static $getFacadeName;
20+
21+
public static function __callStatic($name, $arguments)
22+
{
23+
$instance = new static::$getFacadeName;
24+
25+
if (!$instance)
26+
throw new RuntimeException('A facade root has not been set.');
27+
28+
return $instance->$name(...$arguments);
29+
}
30+
}

src/Facade/StrUtility.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/**
4+
* @Package: some useful php string utility methods
5+
* @Class : StrUtility
6+
* @Author : Nima jahan bakhshian / dvlpr1996 <nimajahanbakhshian@gmail.com>
7+
* @URL : https://github.com/dvlpr1996
8+
* @License: MIT License Copyright (c) 2022 (until present) Nima jahan bakhshian
9+
*/
10+
11+
declare(strict_types=1);
12+
13+
namespace PhpStringHelpers\Facade;
14+
15+
use PhpStringHelpers\Facade\Facade;
16+
17+
class StrUtility extends Facade
18+
{
19+
protected static $getFacadeName = '\PhpStringHelpers\utility\StrUtility';
20+
}

src/PhpStringHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
declare(strict_types=1);
1111

12-
use PhpStringHelpers\utility\StrUtility as strHelpers;
12+
use PhpStringHelpers\Facade\StrUtility as strHelpers;
1313

1414
if (!function_exists('toCamelCase')) {
1515
function toCamelCase(string $words): string

0 commit comments

Comments
 (0)