Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
GLTFBufferView
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
110
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
110
1<?php
2
3namespace MediaWiki\Extension\GLTFHandler\Parser;
4
5use InvalidArgumentException;
6
7final class GLTFBufferView {
8
9    public const TARGET_ARRAY_BUFFER = 34962;
10    public const TARGET_ELEMENT_ARRAY_BUFFER = 34963;
11
12    public function __construct(
13        public int $buffer,
14        public int $byte_length,
15        public int $byte_offset,
16        public ?int $byte_stride,
17        public ?int $target,
18        public ?string $name,
19        public array $extensions,
20        public array $extras
21    ) {
22        $this->buffer >= 0 || throw new InvalidArgumentException( "Expected 'buffer' >= 0, got {$this->buffer}" );
23        $this->byte_length >= 1 || throw new InvalidArgumentException( "Expected 'byteLength' >= 1, got {$this->byte_length}" );
24        $this->byte_offset >= 0 || throw new InvalidArgumentException( "Expected 'byteOffset' >= 0, got {$this->byte_offset}" );
25        if ( $this->byte_stride !== null && ( $this->byte_stride < 4 || $this->byte_stride > 252 ) ) {
26            throw new InvalidArgumentException( "Expected 'byteStride' >= 4, <= 252, got {$this->byte_stride}" );
27        }
28        if ( $this->target !== null && $this->target !== self::TARGET_ARRAY_BUFFER && $this->target !== self::TARGET_ELEMENT_ARRAY_BUFFER ) {
29            throw new InvalidArgumentException( "Expected 'target' to be one of: " . self::TARGET_ARRAY_BUFFER . ", " . self::TARGET_ELEMENT_ARRAY_BUFFER . ", got {$this->target}" );
30        }
31    }
32}