Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -40,19 +40,19 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Webhook
*
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $user_id
* @property bool $active
* @property int $trigger
* @property int $response
* @property int $delivery
* @property string $url
* @property-read User $user
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property int $user_id
* @property bool $active
* @property int $trigger
* @property int $response
* @property int $delivery
* @property string $url
* @property-read User $user
* @property-read Collection|WebhookMessage[] $webhookMessages
* @property-read int|null $webhook_messages_count
* @property-read int|null $webhook_messages_count
* @method static Builder|Webhook newModelQuery()
* @method static Builder|Webhook newQuery()
* @method static \Illuminate\Database\Query\Builder|Webhook onlyTrashed()
@@ -70,11 +70,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|Webhook withTrashed()
* @method static \Illuminate\Database\Query\Builder|Webhook withoutTrashed()
* @mixin Eloquent
* @property string $title
* @property string $secret
* @property string $title
* @property string $secret
* @method static Builder|Webhook whereSecret($value)
* @method static Builder|Webhook whereTitle($value)
* @property int|null $user_group_id
* @property int|null $user_group_id
* @method static Builder|Webhook whereUserGroupId($value)
*/
class Webhook extends Model
@@ -90,10 +90,91 @@ class Webhook extends Model
];
protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'url', 'title', 'secret'];
/**
* @return array
*/
public static function getDeliveries(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveriesForValidation(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponses(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getResponsesForValidation(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getTriggers(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getTriggersForValidation(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
* @param string $value
*
* @return Webhook
* @throws NotFoundHttpException
@@ -101,7 +182,7 @@ class Webhook extends Model
public static function routeBinder(string $value): Webhook
{
if (auth()->check()) {
$webhookId = (int) $value;
$webhookId = (int)$value;
/** @var User $user */
$user = auth()->user();
/** @var Webhook $webhook */
@@ -130,85 +211,4 @@ class Webhook extends Model
{
return $this->hasMany(WebhookMessage::class);
}
/**
* @return array
*/
public static function getTriggers(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getTriggersForValidation(): array
{
$array = [];
$set = WebhookTrigger::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponsesForValidation(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveriesForValidation(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->name] = $item->value;
$array[$item->value] = $item->value;
}
return $array;
}
/**
* @return array
*/
public static function getResponses(): array
{
$array = [];
$set = WebhookResponse::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
/**
* @return array
*/
public static function getDeliveries(): array
{
$array = [];
$set = WebhookDelivery::cases();
foreach ($set as $item) {
$array[$item->value] = $item->name;
}
return $array;
}
}