squareetlabs /
LaravelToon
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Squareetlabs\LaravelToon\Traits; |
||
| 6 | |||
| 7 | use Squareetlabs\LaravelToon\Services\ToonService; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Trait para agregar capacidades TOON a modelos Eloquent o clases |
||
| 11 | * |
||
| 12 | * @mixin \Illuminate\Database\Eloquent\Model |
||
| 13 | */ |
||
| 14 | trait HasToonEncoding |
||
| 15 | { |
||
| 16 | public function toToon(string $format = 'readable'): string |
||
| 17 | { |
||
| 18 | return app(ToonService::class)->convert($this->toArray(), $format); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 19 | } |
||
| 20 | |||
| 21 | public function toToonCompact(): string |
||
| 22 | { |
||
| 23 | return app(ToonService::class)->encodeCompact($this->toArray()); |
||
| 24 | } |
||
| 25 | |||
| 26 | public function toToonReadable(): string |
||
| 27 | { |
||
| 28 | return app(ToonService::class)->encodeReadable($this->toArray()); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getToonMetrics(): array |
||
| 32 | { |
||
| 33 | return app(ToonService::class)->getMetrics($this->toArray()); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getToonCompressionRatio(): float |
||
| 37 | { |
||
| 38 | return app(ToonService::class)->calculateCompressionRatio($this->toArray()); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 |