Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"fakerphp/faker": "^1.20",
"neitanod/forceutf8": "^2.0",
"ramsey/uuid": "^4.7",
"ext-ftp": "*"
"ext-ftp": "*",
"ext-openssl": "*"
},
"require-dev": {
"pda/pheanstalk": "^5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Bow\Http\Exception\UnauthorizedException;

$auth = auth();

$logged = $auth->attemps(["username" => "name@example.com", "password" => "password"]);
$logged = $auth->attempts(["username" => "name@example.com", "password" => "password"]);

if (!$logged) {
throw new UnauthorizedException("Access denied");
Expand Down
8 changes: 7 additions & 1 deletion src/Notification/CanSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

trait CanSendNotification
{
public function sendNotification(Notification $notification)
/**
* Send notification from authenticate user
*
* @param Notification $notification
* @return void
*/
public function sendNotification(Notification $notification): void
{
$notification->process($this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notification/Channel/ChannelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ interface ChannelInterface
* @param mixed $message
* @return void
*/
public function send(mixed $message);
public function send(mixed $message): void;
}
2 changes: 1 addition & 1 deletion src/Notification/Channel/DatabaseChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DatabaseChannel implements ChannelInterface
* @param mixed $message
* @return void
*/
public function send(mixed $message)
public function send(mixed $message): void
{
}
}
3 changes: 1 addition & 2 deletions src/Notification/Channel/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Bow\Mail\Mail;
use Bow\Mail\Message;
use Bow\Notification\Channel\ChannelInterface;

class MailChannel implements ChannelInterface
{
Expand All @@ -14,7 +13,7 @@ class MailChannel implements ChannelInterface
* @param mixed $message
* @return void
*/
public function send(mixed $message)
public function send(mixed $message): void
{
if ($message instanceof Message) {
Mail::getInstance()->send($message);
Expand Down
16 changes: 7 additions & 9 deletions src/Notification/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,26 @@ abstract class Notification
/**
* Returns the available channels to be used
*
* @param \Bow\Database\Barry\Model $notifiable
* @param Model $notifiable
* @return array
*/
abstract public function channels(Model $notifiable): array;

/**
* Send notification to mail
*
* @param \Bow\Database\Barry\Model $notifiable
* @return mixed
* @param Model $notifiable
* @return Message|null
*/
public function toMail(Model $notifiable): ?Message
{
$message = new Message();

return $message;
return new Message();
}

/**
* Send notification to database
*
* @param \Bow\Database\Barry\Model $notifiable
* @param Model $notifiable
* @return array
*/
public function toDatabase(Model $notifiable): array
Expand All @@ -53,10 +51,10 @@ public function toDatabase(Model $notifiable): array

/**
* Process the notification
* @param \Bow\Database\Barry\Model $notifiable
* @param Model $notifiable
* @return void
*/
final function process(Model $notifiable)
final function process(Model $notifiable): void
{
$channels = $this->channels($notifiable);

Expand Down
1 change: 1 addition & 0 deletions src/Queue/Adapters/BeanstalkdAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function run(string $queue = null): void
} else {
$this->pheanstalk->release($job, $this->getPriority($producer->getPriority()), $producer->getDelay());
}

$this->sleep(1);
}
}
Expand Down
21 changes: 12 additions & 9 deletions src/Queue/Adapters/SQSAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ public function size(string $queue): int
*
* @param ?string $queue
* @return void
* @throws \ErrorException
*/
public function run(?string $queue = null): void
{
$this->sleep($this->sleep ?? 5);
$message = null;

try {
$result = $this->sqs->receiveMessage([
Expand Down Expand Up @@ -130,31 +132,31 @@ public function run(?string $queue = null): void
error_log($e->getMessage());
app('logger')->error($e->getMessage(), $e->getTrace());

if (isset($message)) {
cache(
"job:failed:" . $message["ReceiptHandle"],
$message["Body"]
);
if (!$message) {
$this->sleep(1);
return;
}

cache("job:failed:" . $message["ReceiptHandle"], $message["Body"]);

// Check if producer has been loaded
if (!isset($producer)) {
$this->sleep(1);
return;
}

// Execute the onException method for notify the producer
// and let developper to decide if the job should be delete
// and let developer decide if the job should be deleted
$producer->onException($e);

// Check if the job should be delete
// Check if the job should be deleted
if ($producer->jobShouldBeDelete()) {
$result = $this->sqs->deleteMessage([
$this->sqs->deleteMessage([
'QueueUrl' => $this->config["url"],
'ReceiptHandle' => $message['ReceiptHandle']
]);
} else {
$result = $this->sqs->changeMessageVisibilityBatch([
$this->sqs->changeMessageVisibilityBatch([
'QueueUrl' => $this->config["url"],
'Entries' => [
'Id' => $producer->getId(),
Expand All @@ -163,6 +165,7 @@ public function run(?string $queue = null): void
],
]);
}

$this->sleep(1);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Queue/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Connection
/**
* The supported connection
*
* @param array
* @var array
*/
private static array $connections = [
"beanstalkd" => BeanstalkdAdapter::class,
Expand All @@ -50,11 +50,12 @@ public function __construct(array $config)
}

/**
* Push the new connection support in connectors managment
* Push the new connection support in connectors management
*
* @param string $name
* @param string $name
* @param string $classname
* @return bool
* @throws ErrorException
*/
public static function pushConnection(string $name, string $classname): bool
{
Expand Down
28 changes: 14 additions & 14 deletions src/Queue/ProducerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ abstract class ProducerService
/**
* Define the job attempts
*
* @return integer
* @var int
*/
protected int $attemps = 2;
protected int $attempts = 2;

/**
* ProducerService constructor
*
* @return mixed
* @return void
*/
public function __construct()
{
Expand Down Expand Up @@ -90,13 +90,13 @@ public function getId(): string
}

/**
* Get the producer attemps
* Get the producer attempts
*
* @return int
*/
public function getAttemps(): int
public function getAttempts(): int
{
return $this->attemps;
return $this->attempts;
}

/**
Expand Down Expand Up @@ -132,14 +132,14 @@ final public function getDelay(): int


/**
* Set the producer attemps
* Set the producer attempts
*
* @param int $attemps
* @param int $attempts
* @return void
*/
public function setAttemps(int $attemps)
public function setAttempts(int $attempts): void
{
$this->attemps = $attemps;
$this->attempts = $attempts;
}

/**
Expand All @@ -148,7 +148,7 @@ public function setAttemps(int $attemps)
* @param int $retry
* @return void
*/
final public function setRetry(int $retry)
final public function setRetry(int $retry): void
{
$this->retry = $retry;
}
Expand All @@ -159,7 +159,7 @@ final public function setRetry(int $retry)
* @param string $queue
* @return void
*/
final public function setQueue(string $queue)
final public function setQueue(string $queue): void
{
$this->queue = $queue;
}
Expand All @@ -169,7 +169,7 @@ final public function setQueue(string $queue)
*
* @param int $delay
*/
final public function setDelay(int $delay)
final public function setDelay(int $delay): void
{
$this->delay = $delay;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public function onException(\Throwable $e)
/**
* Process the producer
*
* @return mixed
* @return void
*/
abstract public function process(): void;
}
4 changes: 2 additions & 2 deletions src/Queue/WorkerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class WorkerService
/**
* Make connection base on default name
*
* @param string $name
* @return QueueAdapter
* @param QueueAdapter $connection
* @return void
*/
public function setConnection(QueueAdapter $connection): void
{
Expand Down
6 changes: 3 additions & 3 deletions src/Router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Bow\Container\Action;
use Bow\Configuration\Loader;
use Bow\Http\Request;

class Route
{
Expand Down Expand Up @@ -133,10 +132,10 @@ public function middleware(array|string $middleware): Route
* Add the url rules
*
* @param array|string $where
* @param string $regex_constraint
* @param string|null $regex_constraint
* @return Route
*/
public function where(array|string $where, $regex_constraint = null): Route
public function where(array|string $where, string $regex_constraint = null): Route
{
$other_rule = is_array($where) ? $where : [$where => $regex_constraint];

Expand Down Expand Up @@ -176,6 +175,7 @@ public function call(): mixed
* To give a name to the road
*
* @param string $name
* @return Route
*/
public function name(string $name): Route
{
Expand Down
16 changes: 6 additions & 10 deletions src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Router
protected string $prefix = '';

/**
* @var string
* @var ?string
*/
protected ?string $special_method = null;

Expand Down Expand Up @@ -74,7 +74,7 @@ class Router
* Define the request _method parse to form
* for helper router define a good method called
*
* @var string
* @var ?string
*/
private ?string $magic_method;

Expand Down Expand Up @@ -136,11 +136,7 @@ public function prefix(string $prefix, callable $cb): Router
$prefix = '/' . $prefix;
}

if ($this->prefix !== null) {
$this->prefix .= $prefix;
} else {
$this->prefix = $prefix;
}
$this->prefix .= $prefix;

call_user_func_array($cb, [$this]);

Expand Down Expand Up @@ -304,7 +300,7 @@ public function patch(string $path, callable|string|array $cb): Route
* Add a OPTIONS route
*
* @param string $path
* @param callable $cb
* @param callable|string|array $cb
* @return Route
*/
public function options(string $path, callable|string|array $cb): Route
Expand All @@ -317,7 +313,7 @@ public function options(string $path, callable|string|array $cb): Route
* When the define code match with response code.
*
* @param int $code
* @param callable $cb
* @param callable|array|string $cb
* @return Router
*/
public function code(int $code, callable|array|string $cb): Router
Expand Down Expand Up @@ -370,7 +366,7 @@ private function pushHttpVerb(string|array $methods, string $path, callable|stri
/**
* Start loading a route.
*
* @param string|array $method
* @param string|array $methods
* @param string $path
* @param callable|string|array $cb
* @return Route
Expand Down
Loading
Loading