Lint PHP code psr-12, add GH action

This commit is contained in:
Julien Nahum
2024-02-23 11:54:12 +01:00
parent e85e4df7fe
commit 62971a2ef4
226 changed files with 2338 additions and 2144 deletions

View File

@@ -3,10 +3,8 @@
namespace App\Http\Resources;
use App\Http\Middleware\Form\ProtectedForm;
use App\Http\Resources\UserResource;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class FormResource extends JsonResource
{
@@ -20,7 +18,7 @@ class FormResource extends JsonResource
*/
public function toArray($request)
{
if(!$this->userIsFormOwner() && ProtectedForm::isProtected($request, $this->resource)){
if (! $this->userIsFormOwner() && ProtectedForm::isProtected($request, $this->resource)) {
return $this->getProtectedForm();
}
@@ -69,6 +67,7 @@ class FormResource extends JsonResource
public function setCleanings(array $cleanings)
{
$this->cleanings = $cleanings;
return $this;
}
@@ -96,15 +95,18 @@ class FormResource extends JsonResource
];
}
private function getWorkspace() {
private function getWorkspace()
{
return $this->extra?->loadedWorkspace ?? $this->workspace;
}
private function workspaceIsPro() {
private function workspaceIsPro()
{
return $this->extra?->workspaceIsPro ?? $this->getWorkspace()->is_pro ?? $this->is_pro;
}
private function userIsFormOwner() {
private function userIsFormOwner()
{
return $this->extra?->userIsOwner ??
(
Auth::check() && Auth::user()->ownsForm($this->resource)

View File

@@ -6,7 +6,6 @@ use Illuminate\Http\Resources\Json\JsonResource;
class FormSubmissionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
@@ -28,13 +27,14 @@ class FormSubmissionResource extends JsonResource
private function addExtraData()
{
$this->data = array_merge($this->data, [
"created_at" => $this->created_at->toDateTimeString(),
'id' => $this->id
'created_at' => $this->created_at->toDateTimeString(),
'id' => $this->id,
]);
}
/**
* Link to the file (generating signed s3 URL)
*
* @return void
*/
private function generateFileLinks()
@@ -45,7 +45,7 @@ class FormSubmissionResource extends JsonResource
return in_array($field['type'], ['files', 'signature']);
});
foreach ($fileFields as $field) {
if (isset($data[$field['id']]) && !empty($data[$field['id']])) {
if (isset($data[$field['id']]) && ! empty($data[$field['id']])) {
$data[$field['id']] = collect($data[$field['id']])->filter(function ($file) {
return $file !== null && $file;
})->map(function ($file) {

View File

@@ -15,7 +15,7 @@ class FormTemplateResource extends JsonResource
public function toArray($request)
{
return array_merge(parent::toArray($request), [
'is_new' => $this->created_at->isAfter(now()->subDays(7))
'is_new' => $this->created_at->isAfter(now()->subDays(7)),
]);
}
}

View File

@@ -9,7 +9,7 @@ class UserResource extends JsonResource
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)

View File

@@ -3,7 +3,6 @@
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Auth;
class WorkspaceResource extends JsonResource
{
@@ -12,7 +11,7 @@ class WorkspaceResource extends JsonResource
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)