PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
IntArrayTag.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20*/
21
22declare(strict_types=1);
23
24namespace pocketmine\nbt\tag;
25
29use function assert;
30use function func_num_args;
31use function implode;
32use function is_int;
33
34final class IntArrayTag extends ImmutableTag{
36 private $value;
37
41 public function __construct(array $value){
42 self::restrictArgCount(__METHOD__, func_num_args(), 1);
43 assert((function() use(&$value) : bool{
44 foreach($value as $v){
45 if(!is_int($v)){
46 return false;
47 }
48 }
49
50 return true;
51 })());
52
53 $this->value = $value;
54 }
55
56 protected function getTypeName() : string{
57 return "IntArray";
58 }
59
60 public function getType() : int{
61 return NBT::TAG_IntArray;
62 }
63
64 public static function read(NbtStreamReader $reader) : self{
65 return new self($reader->readIntArray());
66 }
67
68 public function write(NbtStreamWriter $writer) : void{
69 $writer->writeIntArray($this->value);
70 }
71
72 protected function stringifyValue(int $indentation) : string{
73 return "[" . implode(",", $this->value) . "]";
74 }
75
79 public function getValue() : array{
80 return $this->value;
81 }
82}