Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 17... Línea 17...
17
    public const MAX_v = 0xFFFF;
17
    public const MAX_v = 0xFFFF;
Línea 18... Línea 18...
18
 
18
 
19
    public function __construct(
19
    public function __construct(
20
        public readonly string $format,
20
        public readonly string $format,
21
        public readonly int|string $value
21
        public readonly int|string $value
22
    ) {
-
 
Línea 23... Línea 22...
23
    }
22
    ) {}
24
 
23
 
25
    /**
24
    /**
26
     * Create a format string and argument list for pack(), then call
25
     * Create a format string and argument list for pack(), then call
Línea 31... Línea 30...
31
        $fmt = array_reduce($fields, function (string $acc, self $field) {
30
        $fmt = array_reduce($fields, function (string $acc, self $field) {
32
            return $acc . $field->format;
31
            return $acc . $field->format;
33
        }, '');
32
        }, '');
Línea 34... Línea 33...
34
 
33
 
35
        $args = array_map(function (self $field) {
34
        $args = array_map(function (self $field) {
36
            switch($field->format) {
35
            switch ($field->format) {
37
                case 'V':
36
                case 'V':
38
                    if ($field->value > self::MAX_V) {
37
                    if ($field->value > self::MAX_V) {
39
                        throw new RuntimeException(print_r($field->value, true) . ' is larger than 32 bits');
38
                        throw new RuntimeException(print_r($field->value, true) . ' is larger than 32 bits');
40
                    }
39
                    }