Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Scale
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toMatrix
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Svg\Value\Transform;
6
7use Phpdftk\Svg\Value\TransformFunction;
8
9/**
10 * `scale(sx)` or `scale(sx, sy)`. When `sy` is omitted it defaults to `sx`
11 * (uniform scale) — distinct from translate's "second arg defaults to 0".
12 */
13final class Scale implements TransformFunction
14{
15    public function __construct(
16        public readonly float $sx,
17        public readonly ?float $sy = null,
18    ) {}
19
20    public function toMatrix(): array
21    {
22        $sy = $this->sy ?? $this->sx;
23        return [$this->sx, 0.0, 0.0, $sy, 0.0, 0.0];
24    }
25}