This commit is contained in:
2023-12-01 10:19:53 +08:00
parent 3c72ca7175
commit 4211f27d88
2 changed files with 98 additions and 86 deletions
+5 -4
View File
@@ -47,20 +47,21 @@ class Kiri
/** /**
* @param $className * @param string|array $className
* @param array $construct * @param array $construct
* @return mixed * @return mixed
* @throws Exception * @throws Exception
*/ */
public static function createObject($className, array $construct = []): mixed public static function createObject(string|array $className, array $construct = []): mixed
{ {
$container = static::getContainer();
if (is_string($className) && class_exists($className)) { if (is_string($className) && class_exists($className)) {
$object = static::getContainer()->get($className); $object = $container->get($className);
return self::configure($object, $construct); return self::configure($object, $construct);
} else if (is_array($className) && isset($className['class'])) { } else if (is_array($className) && isset($className['class'])) {
$class = $className['class']; $class = $className['class'];
unset($className['class']); unset($className['class']);
return static::getContainer()->make($class, $construct, $className); return $container->make($class, $construct, $className);
} else if (is_callable($className, TRUE)) { } else if (is_callable($className, TRUE)) {
return call_user_func($className, $construct); return call_user_func($className, $construct);
} else { } else {
+12 -1
View File
@@ -10,7 +10,6 @@ declare(strict_types=1);
namespace Kiri\Core; namespace Kiri\Core;
/** /**
* Class DateFormat * Class DateFormat
* @package Kiri\Core * @package Kiri\Core
@@ -18,6 +17,18 @@ namespace Kiri\Core;
class DateFormat class DateFormat
{ {
/**
* @return int
*/
public static function DaySecond(): int
{
$time = strtotime(date('Y-m-d', strtotime('+1days')));
return $time - time();
}
/** /**
* @param $time * @param $time
* @return bool|false|int|string * @return bool|false|int|string