Skip to content

Commit f0c3ae4

Browse files
committed
refonte: action to compass
1 parent f098006 commit f0c3ae4

8 files changed

Lines changed: 33 additions & 31 deletions

File tree

src/Application/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use Bow\Application\Exception\ApplicationException;
88
use Bow\Configuration\Loader;
9-
use Bow\Container\Action;
109
use Bow\Container\Capsule;
10+
use Bow\Container\Compass;
1111
use Bow\Contracts\ResponseInterface;
1212
use Bow\Http\Exception\BadRequestException;
1313
use Bow\Http\Exception\HttpException;
@@ -182,7 +182,7 @@ public function send(): bool
182182
);
183183
}
184184

185-
$response = Action::getInstance()->execute($this->error_code[404], []);
185+
$response = Compass::getInstance()->execute($this->error_code[404], []);
186186

187187
$this->sendResponse($response, 404);
188188

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
use ReflectionException;
1717
use ReflectionFunction;
1818

19-
class Action
19+
class Compass
2020
{
2121
private const INJECTION_EXCEPTION_TYPE = [
2222
'string', 'array', 'bool', 'int',
2323
'integer', 'double', 'float', 'callable',
2424
'object', 'stdclass', '\closure', 'closure'
2525
];
2626
/**
27-
* The Action instance
27+
* The Compass instance
2828
*
29-
* @var ?Action
29+
* @var ?Compass
3030
*/
31-
private static ?Action $instance = null;
31+
private static ?Compass $instance = null;
3232
/**
3333
* The list of namespaces defined in the application
3434
*
@@ -49,7 +49,7 @@ class Action
4949
private MiddlewareDispatcher $dispatcher;
5050

5151
/**
52-
* Action constructor
52+
* Compass constructor
5353
*
5454
* @param array $namespaces
5555
* @param array $middlewares
@@ -64,17 +64,17 @@ public function __construct(array $namespaces, array $middlewares)
6464
}
6565

6666
/**
67-
* Action configuration
67+
* Compass configuration
6868
*
6969
* @param array $namespaces
7070
* @param array $middlewares
7171
*
7272
* @return static
7373
*/
74-
public static function configure(array $namespaces, array $middlewares): Action
74+
public static function configure(array $namespaces, array $middlewares): Compass
7575
{
7676
if (is_null(static::$instance)) {
77-
static::$instance = new Action($namespaces, $middlewares);
77+
static::$instance = new Compass($namespaces, $middlewares);
7878
}
7979

8080
return static::$instance;
@@ -263,11 +263,11 @@ public function call(callable|string|array $actions, ?array $param = null): mixe
263263
}
264264

265265
/**
266-
* Retrieves Action instance
266+
* Retrieves Compass instance
267267
*
268-
* @return Action
268+
* @return Compass
269269
*/
270-
public static function getInstance(): Action
270+
public static function getInstance(): Compass
271271
{
272272
return static::$instance;
273273
}
@@ -372,7 +372,7 @@ private function getInjectParameter(mixed $class): ?object
372372
{
373373
$class_name = $class->getName();
374374

375-
if (in_array(strtolower($class_name), Action::INJECTION_EXCEPTION_TYPE)) {
375+
if (in_array(strtolower($class_name), Compass::INJECTION_EXCEPTION_TYPE)) {
376376
return null;
377377
}
378378

src/Container/ContainerConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function create(Loader $config): void
2424
$this->container->bind('action', function () use ($config) {
2525
$middlewares = array_merge($config->getMiddlewares(), $this->middlewares);
2626

27-
return Action::configure($config->namespaces(), $middlewares);
27+
return Compass::configure($config->namespaces(), $middlewares);
2828
});
2929
}
3030

src/Database/QueryBuilder.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ public function remove(string $column, mixed $comparator = '=', $value = null):
11751175
}
11761176

11771177
/**
1178-
* Delete Action
1178+
* Delete Compass
11791179
*
11801180
* @return int
11811181
*/
@@ -1203,7 +1203,7 @@ public function delete(): int
12031203
}
12041204

12051205
/**
1206-
* Action increment, add 1 by default to the specified field
1206+
* Compass increment, add 1 by default to the specified field
12071207
*
12081208
* @param string $column
12091209
* @param int $step
@@ -1272,7 +1272,7 @@ public function distinct(string $column)
12721272
}
12731273

12741274
/**
1275-
* Truncate Action, empty the table
1275+
* Truncate Compass, empty the table
12761276
*
12771277
* @return bool
12781278
*/
@@ -1306,7 +1306,7 @@ public function insertAndGetLastId(array $values): string|int|bool
13061306
}
13071307

13081308
/**
1309-
* Insert Action
1309+
* Insert Compass
13101310
*
13111311
* The data to be inserted into the database.
13121312
*
@@ -1362,7 +1362,7 @@ private function insertOne(array $value): int
13621362
}
13631363

13641364
/**
1365-
* Drop Action, remove the table
1365+
* Drop Compass, remove the table
13661366
*
13671367
* @return mixed
13681368
*/

src/Mail/Envelop.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ public function view(string $view, array $data = []): Envelop
492492
}
493493

494494
/**
495+
* Alias of setMessage
496+
*
495497
* @param string $message
496498
* @param string $type
497499
* @see setEnvelop

src/Messaging/Messaging.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function toTelegram(Model $context): array
9898
* @param Model $context
9999
* @return void
100100
*/
101-
public final function process(Model $context): void
101+
final public function process(Model $context): void
102102
{
103103
$channels = $this->channels($context);
104104

src/Router/Route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Bow\Router;
66

77
use Bow\Configuration\Loader;
8-
use Bow\Container\Action;
8+
use Bow\Container\Compass;
99

1010
class Route
1111
{
@@ -158,7 +158,7 @@ public function call(): mixed
158158
$this->match[$key] = $tmp;
159159
}
160160

161-
return Action::getInstance()->call($this->cb, $this->match);
161+
return Compass::getInstance()->call($this->cb, $this->match);
162162
}
163163

164164
/**

tests/Messaging/MessagingTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ public static function setUpBeforeClass(): void
3232
]);
3333
}
3434

35-
protected function setUp(): void
36-
{
37-
parent::setUp();
38-
39-
$this->context = $this->createMock(TestNotifiableModel::class);
40-
$this->message = $this->createMock(TestMessage::class);
41-
}
42-
4335
public function test_can_send_message_synchronously(): void
4436
{
4537
$this->message->expects($this->once())
@@ -191,4 +183,12 @@ public function test_message_can_send_to_telegram(): void
191183
$this->assertEquals('Test Telegram message', $data['message']);
192184
$this->assertEquals('HTML', $data['parse_mode']);
193185
}
186+
187+
protected function setUp(): void
188+
{
189+
parent::setUp();
190+
191+
$this->context = $this->createMock(TestNotifiableModel::class);
192+
$this->message = $this->createMock(TestMessage::class);
193+
}
194194
}

0 commit comments

Comments
 (0)