Skip to content

Commit

Permalink
Format code with new pint config
Browse files Browse the repository at this point in the history
  • Loading branch information
rawilk committed Mar 6, 2024
1 parent 5bbd0da commit ef7b404
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions config/human-keys.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

return [
/*
|--------------------------------------------------------------------------
Expand Down
34 changes: 17 additions & 17 deletions src/Concerns/HasHumanKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
/** @mixin \Illuminate\Database\Eloquent\Model */
trait HasHumanKey
{
public function initializeHasHumanKey(): void
{
if (in_array($this->getKeyName(), $this->humanKeys(), true)) {
$this->keyType = 'string';
$this->incrementing = false;
}
}

public static function bootHasHumanKey(): void
{
static::creating(static function (Model $model) {
Expand All @@ -34,6 +26,23 @@ public static function bootHasHumanKey(): void
});
}

public static function humanKeyPrefix(): string
{
return Str::of(static::class)
->classBasename()
->lower()
->limit(3, '')
->toString();
}

public function initializeHasHumanKey(): void
{
if (in_array($this->getKeyName(), $this->humanKeys(), true)) {
$this->keyType = 'string';
$this->incrementing = false;
}
}

/**
* Get the columns that should receive human-readable keys.
*/
Expand All @@ -46,13 +55,4 @@ public function newHumanKey(): string
{
return HumanKeys::generate(static::humanKeyPrefix());
}

public static function humanKeyPrefix(): string
{
return Str::of(static::class)
->classBasename()
->lower()
->limit(3, '')
->toString();
}
}
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Rawilk\HumanKeys\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);

0 comments on commit ef7b404

Please sign in to comment.