Skip to content

Commit cc37418

Browse files
committed
Switching to PHP-Utilities package
1 parent 54b4dcc commit cc37418

16 files changed

+20
-212
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
"email": "anshu.krishna5@gmail.com"
1010
}
1111
],
12-
"version": "11.0.2",
12+
"version": "11.1",
1313
"minimum-stability": "stable",
1414
"require": {
1515
"php": ">=8.1",
16-
"anshu-krishna/data-validator": "^2.0"
16+
"anshu-krishna/data-validator": "^2.0",
17+
"anshu-krishna/php-utilities": "^1.0"
1718
},
1819
"autoload": {
1920
"psr-4": {

example/server/function/@Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
use Krishna\API\Func;
44

55
Func::set_definition(function(array $params, string $funcname) {
6-
\Krishna\API\Debugger::dump('Test', 'Testing debug message');
6+
\Krishna\Utilities\Debugger::dump('Test', 'Testing debug message');
77
return 'This is default response';
88
});

src/Base64.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace Krishna\API;
33

44
final class Config {
5-
use StaticOnlyTrait;
5+
use \Krishna\Utilities\StaticOnlyTrait;
66
// Flags
77
public static bool
88
$dev_mode = false,

src/Consumable.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Krishna\API;
33

4+
use Krishna\Utilities\Debugger;
5+
46
final class Consumable {
57
public int $count;
68
public bool $has_more;

src/DataType/FlagType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Krishna\DataValidator\Returner;
55

66
class FlagType implements \Krishna\DataValidator\TypeInterface {
7-
use \Krishna\DataValidator\StaticOnlyTrait;
7+
use \Krishna\Utilities\StaticOnlyTrait;
88
const Name = 'flag';
99
const Consume = 0;
1010

src/DataType/Json64Type.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/DataType/JsonType.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/DataType/String64Type.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/DataType/URL64Type.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Debugger.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/Func.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
use Krishna\DataValidator\MultiLinedException;
55
use Krishna\DataValidator\ObjectHandler;
6+
use Krishna\DataValidator\OutOfBoundAction;
67
use Krishna\DataValidator\Validator;
7-
88
final class Func {
9-
use StaticOnlyTrait;
9+
use \Krishna\Utilities\StaticOnlyTrait;
1010
private static $definition = null;
1111
private static array $auth = [];
1212
private static $signature = null;
@@ -19,9 +19,9 @@ public static function add_authenticator(AuthenticatorInterface ...$handlers) {
1919
self::$auth[] = $h;
2020
}
2121
}
22-
public static function set_signature(array $signature) {
22+
public static function set_signature(array $signature, OutOfBoundAction $on_out_of_bound = OutOfBoundAction::Trim) {
2323
try {
24-
self::$signature = new Validator($signature, true);
24+
self::$signature = new Validator($signature, $on_out_of_bound);
2525
if(!is_a(self::$signature->struct, ObjectHandler::class)) {
2626
throw new MultiLinedException('Invalid signature; It has to be a object structure');
2727
}

src/JSON.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Server.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
namespace Krishna\API;
33

44
use Krishna\DataValidator\TypeHandler;
5+
use Krishna\Utilities\Debugger;
6+
use Krishna\Utilities\JSON;
57

68
final class Server {
7-
use StaticOnlyTrait;
9+
use \Krishna\Utilities\StaticOnlyTrait;
810

911
private static array
1012
$request = [
@@ -59,18 +61,17 @@ public static function init(?string $func_base_path = null) :void {
5961
}
6062
}
6163
});
64+
65+
// Init Debugger
66+
Debugger::$dumpper = [Server::class, 'add_debug_msg'];
6267

6368
// Init paths
6469
self::$func_base_path = realpath($func_base_path ?? (getcwd() . '/../function'));
6570
self::$func_base_path = (self::$func_base_path === false) ? (getcwd() . '/') : (self::$func_base_path . '/');
6671

6772
// Init Custom Validator DataTypes
6873
TypeHandler::set_multiple_custom_type_class([
69-
'flag' => 'FlagType',
70-
'string64' => 'String64Type',
71-
'json' => 'JsonType',
72-
'json64' => 'Json64Type',
73-
'url64' => 'URL64Type'
74+
'flag' => 'FlagType'
7475
], '\\Krishna\\API\\DataType');
7576

7677
// Init request info

src/StaticOnlyTrait.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/TypeInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace Krishna\API;
33

44
final class TypeInfo {
5-
use StaticOnlyTrait;
5+
use \Krishna\Utilities\StaticOnlyTrait;
66
private static array $consume_info = [];
77
public static function get(string $type) {
88
if(array_key_exists($type, self::$consume_info)) {

0 commit comments

Comments
 (0)