56 private $parsed =
false;
58 private $entityPrefix =
'';
59 private $entityId = 0;
65 public static function isValid($code): bool
67 foreach (self::$map as $pattern => $type)
69 if (preg_match(
'/'. $pattern .
'/', $code, $matches))
83 $this->accessCode = $accessCode;
96 return $this->entityPrefix . $this->entityId;
104 return $this->entityType;
112 return $this->entityPrefix;
120 return $this->entityId;
126 private function parse()
128 foreach (self::$map as $pattern => $type)
130 if (preg_match(
'/'. $pattern .
'/', $this->accessCode, $matches))
132 $this->parsed =
true;
133 $this->entityType = $type;
134 $this->entityPrefix = (string) $matches[1];
135 if (array_key_exists(
'2', $matches))
137 $this->entityId = (int) $matches[2];
const TYPE_ACCESS_DIRECTOR
__construct(string $accessCode)
const TYPE_ACCESS_EMPLOYEE