Implement PHP CS Fixer and a coding standard to follow (#471)

* Create PHP CS Fixer config and add to CI workflow

* Run php cs fixer on project

* Add newline at end of file

* Update to use PHP CS Fixer v3

* Run v3 config on project

* Run seperate config in CI
This commit is contained in:
Mwikala Kangwa
2021-05-21 12:57:51 +01:00
committed by GitHub
parent 633cad9b89
commit 9e98a96d61
316 changed files with 4715 additions and 3195 deletions

View File

@ -33,7 +33,7 @@ class AddressFactory extends Factory
'phone' => $this->faker->phoneNumber,
'fax' => $this->faker->phoneNumber,
'type' => $this->faker->randomElement([Address::BILLING_TYPE, Address::SHIPPING_TYPE]),
'user_id' => User::factory()
'user_id' => User::factory(),
];
}
}

View File

@ -23,7 +23,7 @@ class CompanyFactory extends Factory
{
return [
'unique_hash' => str_random(60),
'name' => $this->faker->name
'name' => $this->faker->name,
];
}
}

View File

@ -27,7 +27,7 @@ class CustomFieldFactory extends Factory
'label' => $this->faker->name,
'order' => $this->faker->randomDigitNotNull,
'is_required' => $this->faker->randomElement([true, false]),
'model_type'=> $this->faker->randomElement(['Customer', 'Invoice', 'Estimate', 'Expense', 'Payment']),
'model_type' => $this->faker->randomElement(['Customer', 'Invoice', 'Estimate', 'Expense', 'Payment']),
'slug' => function (array $item) {
return clean_slug($item['model_type'], $item['label']);
},

View File

@ -2,8 +2,8 @@
namespace Database\Factories;
use Crater\Models\CustomFieldValue;
use Crater\Models\CustomField;
use Crater\Models\CustomFieldValue;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

View File

@ -32,7 +32,7 @@ class EmailLogFactory extends Factory
'mailable_type' => $this->faker->randomElement([Invoice::class, Estimate::class, Payment::class]),
'mailable_id' => function (array $log) {
return $log['mailable_type']::factory();
}
},
];
}
}

View File

@ -46,7 +46,7 @@ class EstimateItemFactory extends Factory
},
'discount' => function (array $estimate) {
return $estimate['discount_type'] == 'percentage' ? (($estimate['discount_val'] * $estimate['total']) / 100) : $estimate['discount_val'];
}
},
];
}
}

View File

@ -25,7 +25,7 @@ class ExpenseCategoryFactory extends Factory
return [
'name' => $this->faker->word,
'company_id' => User::where('role', 'super admin')->first()->company_id,
'description' => $this->faker->text
'description' => $this->faker->text,
];
}
}

View File

@ -3,8 +3,8 @@
namespace Database\Factories;
use Crater\Models\Expense;
use Crater\Models\User;
use Crater\Models\ExpenseCategory;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ExpenseFactory extends Factory
@ -29,7 +29,7 @@ class ExpenseFactory extends Factory
'company_id' => User::where('role', 'super admin')->first()->company_id,
'amount' => $this->faker->randomDigitNotNull,
'notes' => $this->faker->text,
'attachment_receipt' => null
'attachment_receipt' => null,
];
}
}

View File

@ -25,10 +25,10 @@ class FileDiskFactory extends Factory
'name' => $this->faker->word,
'driver' => 'local',
'set_as_default' => false,
'credentials' => [
'credentials' => [
'driver' => 'local',
'root' => storage_path('app'),
]
],
];
}

View File

@ -3,8 +3,8 @@
namespace Database\Factories;
use Crater\Models\Invoice;
use Crater\Models\User;
use Crater\Models\InvoiceTemplate;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class InvoiceFactory extends Factory
@ -121,7 +121,7 @@ class InvoiceFactory extends Factory
return $invoice['total'];
},
'notes' => $this->faker->text(80),
'unique_hash' => str_random(60)
'unique_hash' => str_random(60),
];
}
}

View File

@ -3,8 +3,8 @@
namespace Database\Factories;
use Crater\Models\Item;
use Crater\Models\User;
use Crater\Models\Unit;
use Crater\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class ItemFactory extends Factory
@ -28,7 +28,7 @@ class ItemFactory extends Factory
'description' => $this->faker->text,
'company_id' => User::where('role', 'super admin')->first()->company_id,
'price' => $this->faker->randomDigitNotNull,
'unit_id' => Unit::factory()
'unit_id' => Unit::factory(),
];
}
}

View File

@ -24,7 +24,7 @@ class NoteFactory extends Factory
return [
'type' => $this->faker->randomElement(['Invoice', 'Estimate', 'Payment']),
'name' => $this->faker->word,
'notes' => $this->faker->text
'notes' => $this->faker->text,
];
}
}

View File

@ -28,7 +28,7 @@ class PaymentFactory extends Factory
'payment_date' => $this->faker->date('Y-m-d', 'now'),
'notes' => $this->faker->text(80),
'amount' => $this->faker->randomDigitNotNull,
'payment_number' => 'PAY-' . Payment::getNextPaymentNumber('PAY'),
'payment_number' => 'PAY-'.Payment::getNextPaymentNumber('PAY'),
];
}
}

View File

@ -32,7 +32,7 @@ class TaxFactory extends Factory
return TaxType::find($item['tax_type_id'])->name;
},
'company_id' => User::where('role', 'super admin')->first()->company_id,
'amount' => $this->faker->randomDigitNotNull
'amount' => $this->faker->randomDigitNotNull,
];
}
}

View File

@ -24,11 +24,11 @@ class TaxTypeFactory extends Factory
{
return [
'name' => $this->faker->word,
'company_id' => User::where('role','super admin')->first()->company_id,
'company_id' => User::where('role', 'super admin')->first()->company_id,
'percent' => $this->faker->numberBetween($min = 0, $max = 100),
'description' => $this->faker->text,
'compound_tax' => 0,
'collective_tax' => 0
'collective_tax' => 0,
];
}
}

View File

@ -34,7 +34,7 @@ class UserFactory extends Factory
'company_id' => User::find(1)->company_id,
'role' => 'super admin',
'password' => Hash::make('secret'),
'currency_id' => Currency::first()->id
'currency_id' => Currency::first()->id,
];
}
}