HasToonEncoding::toToonCompact()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
It seems like toArray() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return app(ToonService::class)->convert($this->/** @scrutinizer ignore-call */ toArray(), $format);
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