Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Jan 22, 2025
1 parent 0650f51 commit aaaf1bf
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 120 deletions.
9 changes: 4 additions & 5 deletions src/Console/Command/GenerateResourceControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ private function createDefaultView(string $base_directory): void
*/
private function createResourceController(
Generator $generator,
string $prefix,
string $controller,
string $model_namespace = ''
): void
{
string $prefix,
string $controller,
string $model_namespace = ''
): void {
$generator->write('controller/rest', [
'modelNamespace' => $model_namespace,
'prefix' => $prefix,
Expand Down
20 changes: 8 additions & 12 deletions src/Database/Barry/Concerns/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ trait Relationship
* @return BelongsTo
*/
public function belongsTo(
string $related,
string $related,
?string $foreign_key = null,
?string $local_key = null
): BelongsTo
{
): BelongsTo {
// Create the new instance of model from container
$related_model = app()->make($related);

Expand Down Expand Up @@ -56,11 +55,10 @@ abstract public function getKey(): string;
* @return BelongsToMany
*/
public function belongsToMany(
string $related,
string $related,
?string $primary_key = null,
?string $foreign_key = null
): BelongsToMany
{
): BelongsToMany {
$related_model = app()->make($related);

if (is_null($primary_key)) {
Expand All @@ -84,11 +82,10 @@ public function belongsToMany(
* @return HasMany
*/
public function hasMany(
string $related,
string $related,
?string $primary_key = null,
?string $foreign_key = null
): HasMany
{
): HasMany {
$related_model = app()->make($related);

if (is_null($primary_key)) {
Expand All @@ -112,11 +109,10 @@ public function hasMany(
* @return HasOne
*/
public function hasOne(
string $related,
string $related,
?string $foreign_key = null,
?string $primary_key = null
): HasOne
{
): HasOne {
$related_model = app()->make($related);

if (is_null($primary_key)) {
Expand Down
10 changes: 4 additions & 6 deletions src/Database/Barry/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,8 @@ public static function findBy(string $column, mixed $value): Collection
*/
public static function findAndDelete(
int|string|array $id,
array $select = ['*']
): Collection|Model|null
{
array $select = ['*']
): Collection|Model|null {
$model = static::find($id, $select);

if (is_null($model)) {
Expand All @@ -339,9 +338,8 @@ public static function findAndDelete(
*/
public static function find(
int|string|array $id,
array $select = ['*']
): Collection|Model|null
{
array $select = ['*']
): Collection|Model|null {
$id = (array)$id;

$model = new static();
Expand Down
7 changes: 3 additions & 4 deletions src/Database/Barry/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ class BelongsTo extends Relation
* @param string $local_key
*/
public function __construct(
Model $related,
Model $parent,
Model $related,
Model $parent,
string $foreign_key,
string $local_key
)
{
) {
$this->local_key = $local_key;
$this->foreign_key = $foreign_key;

Expand Down
13 changes: 6 additions & 7 deletions src/Database/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
class Pagination
{
public function __construct(
private readonly int $next,
private readonly int $previous,
private readonly int $total,
private readonly int $perPage,
private readonly int $current,
private readonly int $next,
private readonly int $previous,
private readonly int $total,
private readonly int $perPage,
private readonly int $current,
private readonly SupportCollection|DatabaseCollection $data
)
{
) {
}

public function next(): int
Expand Down
43 changes: 19 additions & 24 deletions src/Database/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,10 @@ public function orWhere(string $column, mixed $comparator = '=', mixed $value =
*/
public function where(
string $column,
mixed $comparator = '=',
mixed $value = null,
mixed $comparator = '=',
mixed $value = null,
string $boolean = 'and'
): QueryBuilder
{
): QueryBuilder {

// We check here the applied comparator
if (!static::isComparisonOperator($comparator) || is_null($value)) {
Expand Down Expand Up @@ -543,12 +542,11 @@ public function whereIn(string $column, array $range, string $boolean = 'and'):
* @return QueryBuilder
*/
public function join(
string $table,
string $first,
mixed $comparator = '=',
string $table,
string $first,
mixed $comparator = '=',
?string $second = null
): QueryBuilder
{
): QueryBuilder {
$table = $this->getPrefix() . $table;

if (is_null($this->join)) {
Expand Down Expand Up @@ -603,12 +601,11 @@ public function setPrefix(string $prefix): QueryBuilder
* @throws QueryBuilderException
*/
public function leftJoin(
string $table,
string $first,
mixed $comparator = '=',
string $table,
string $first,
mixed $comparator = '=',
?string $second = null
): QueryBuilder
{
): QueryBuilder {
$table = $this->getPrefix() . $table;

if (is_null($this->join)) {
Expand Down Expand Up @@ -640,12 +637,11 @@ public function leftJoin(
* @throws QueryBuilderException
*/
public function rightJoin(
string $table,
string $first,
mixed $comparator = '=',
string $table,
string $first,
mixed $comparator = '=',
?string $second = null
): QueryBuilder
{
): QueryBuilder {
$table = $this->getPrefix() . $table;

if (is_null($this->join)) {
Expand Down Expand Up @@ -763,11 +759,10 @@ public function groupBy(string $column): QueryBuilder
*/
public function having(
string $column,
mixed $comparator = '=',
$value = null,
$boolean = 'and'
): QueryBuilder
{
mixed $comparator = '=',
$value = null,
$boolean = 'and'
): QueryBuilder {
// We check here the applied comparator
if (!$this->isComparisonOperator($comparator)) {
$value = $comparator;
Expand Down
3 changes: 1 addition & 2 deletions src/Event/EventProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class EventProducer extends ProducerService
public function __construct(
private readonly mixed $event,
private readonly mixed $payload = null,
)
{
) {
parent::__construct();
}

Expand Down
7 changes: 3 additions & 4 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ public function addHeaders(array $headers): Response
* @return string
*/
public function download(
string $file,
string $file,
?string $filename = null,
array $headers = []
): string
{
array $headers = []
): string {
$type = mime_content_type($file);

if (is_null($filename)) {
Expand Down
7 changes: 3 additions & 4 deletions src/Mail/MailQueueProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ class MailQueueProducer extends ProducerService
* @param Message $message
*/
public function __construct(
string $view,
array $data,
string $view,
array $data,
Message $message
)
{
) {
parent::__construct();

$this->bags = [
Expand Down
3 changes: 1 addition & 2 deletions src/Messaging/Channel/DatabaseChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class DatabaseChannel implements ChannelInterface
{
public function __construct(
private readonly array $database
)
{
) {
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Messaging/Channel/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class MailChannel implements ChannelInterface
*/
public function __construct(
private readonly Message $message
)
{
) {
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Queue/Adapters/QueueAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ abstract public function push(ProducerService $producer): void;
*/
public function serializeProducer(
ProducerService $producer
): string
{
): string {
return serialize($producer);
}

Expand All @@ -77,8 +76,7 @@ public function serializeProducer(
*/
public function unserializeProducer(
string $producer
): ProducerService
{
): ProducerService {
return unserialize($producer);
}

Expand Down
11 changes: 5 additions & 6 deletions src/Queue/WorkerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ public function setConnection(QueueAdapter $connection): void
*/
#[NoReturn] public function run(
string $queue = "default",
int $tries = 3,
int $sleep = 5,
int $timeout = 60,
int $memory = 128
): void
{
int $tries = 3,
int $sleep = 5,
int $timeout = 60,
int $memory = 128
): void {
$this->connection->setQueue($queue);
$this->connection->setTries($tries);
$this->connection->setSleep($sleep);
Expand Down
9 changes: 4 additions & 5 deletions src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ class Router
* @param array $middlewares
*/
protected function __construct(
string $method,
string $method,
?string $magic_method = null,
string $base_route = '',
array $middlewares = []
)
{
string $base_route = '',
array $middlewares = []
) {
$this->method = $method;
$this->magic_method = $magic_method;
$this->middlewares = $middlewares;
Expand Down
7 changes: 3 additions & 4 deletions src/Session/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ public static function remove(string $key): string|bool|null
*/
public static function set(
int|string $key,
mixed $data,
int $expiration = 3600,
): bool
{
mixed $data,
int $expiration = 3600,
): bool {
$data = Crypto::encrypt(json_encode($data));

return setcookie(
Expand Down
3 changes: 1 addition & 2 deletions src/Support/Serializes.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public function __serialize()
*/
protected function getPropertyValue(
ReflectionProperty $property
): mixed
{
): mixed {
return $property->getValue($this);
}

Expand Down
Loading

0 comments on commit aaaf1bf

Please sign in to comment.