[ SYSTEM ]: Linux wordpress 6.1.0-44-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
[ SERVER ]: Apache/2.4.66 (Debian) | PHP: 8.2.30
[ USER ]: www-data | IP: 172.19.30.54
GEFORCE FILE MANAGER
/
var
/
www
/
html
/
wordpress
/
wp-content
/
plugins
/
presto-player
/
vendor
/
level-2
/
dice
/
Extra
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 RuleValidator.php
1,677 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: RuleValidator.php
<?php namespace PrestoPlayer\Dice\Extra; class RuleValidator { private $dice; public function __construct(\Dice\Dice $dice) { $this->dice = $dice; } public function addRule($name, array $rule) { $this->checkValidKeys($rule); $this->checkBoolean($rule, 'inherit'); $this->checkBoolean($rule, 'shared'); $this->checkNumericArray($rule, 'constructParams'); $this->checkNumericArray($rule, 'shareInstances'); $this->checkNumericArray($rule, 'call'); $this->dice->addRule($name, $rule); } private function checkValidKeys($rule) { $validKeys = ['call', 'shared', 'substitutions', 'instanceOf', 'inherit', 'shareInstances', 'constructParams']; foreach ($rule as $name => $value) { if (!in_array($name, $validKeys)) throw new \InvalidArgumentException('Invalid rule option: '. $name); } } public function create($name, array $args = [], array $share = []) { return $this->dice->create($name, $args, $share); } public function checkBoolean($rule, $key) { if (!isset($rule[$key])) return; if (!is_bool($rule[$key])) throw new \InvalidArgumentException('Rule option ' . $key . ' must be true or false'); } public function checkNumericArray($rule, $key) { if (!isset($rule[$key])) return; if (count(array_filter(array_keys($rule[$key]), 'is_string')) > 0) throw new \InvalidArgumentException('Rule option ' . $key . ' must be a seqential array not an associative array'); } public function checkAssocArray($rule, $key) { if (!isset($rule[$key])) return; if (count(array_filter(array_keys($rule[$key]), 'is_string')) === 0) throw new \InvalidArgumentException('Rule option ' . $key . ' must be a an associative array'); } }