for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateBotanShortenerTable extends Migration
{
public function up(): void
Schema::create('botan_shortener', static function (Blueprint $table) {
$table->bigInteger('id', true)->unsigned()->comment('Unique identifier for this entry');
$table->bigInteger('user_id')->nullable()->index('user_id')->comment('Unique user identifier');
$table->text('url')->comment('Original URL');
$table->char('short_url')->default('')->comment('Shortened URL');
$table->dateTime('created_at')->nullable()->comment('Entry date creation');
});
}
public function down(): void
Schema::dropIfExists('botan_shortener');