ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MaxNestingPathGenerator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
31{
35 private const MAX_NESTING_256 = 256;
39 private const MAX_NESTING_4096 = 4096;
43 private const MAX_NESTING_65536 = 65536;
44
46 protected int $splitter = 3;
47 protected int $limited_layers = 3;
48
52 public function __construct()
53 {
54 $this->splitter = match ($this->max_nesting) {
55 self::MAX_NESTING_4096 => 3,
56 self::MAX_NESTING_65536 => 4,
57 default => 2,
58 };
59 }
60
61 public function getPathFor(ResourceIdentification $i): string
62 {
63 $splitted = str_split(str_replace("-", "", $i->serialize()), $this->splitter);
64
65 $first_part = array_slice($splitted, 0, $this->limited_layers + 1);
66 $second_part = array_slice($splitted, $this->limited_layers + 1);
67
68 return implode("/", $first_part) . implode("", $second_part);
69 }
70
72 {
73 $str = str_replace("/", "", $path);
74
75 $p1 = substr($str, 0, 8);
76 $p2 = substr($str, 8, 4);
77 $p3 = substr($str, 12, 4);
78 $p4 = substr($str, 16, 4);
79 $p5 = substr($str, 20, 12);
80
81 return new ResourceIdentification("$p1-$p2-$p3-$p4-$p5");
82 }
83}
$path
Definition: ltiservices.php:30