HEX
Server: Apache/2.4.62 (Debian)
System: Linux plxsite 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64
User: root (0)
PHP: 8.1.30
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/admin-menu-editor/customizables/Schemas/CheckableSchema.php
<?php

namespace YahnisElsts\AdminMenuEditor\Customizable\Schemas;

abstract class CheckableSchema extends Schema {
	protected $checks = [];

	protected function addCheck($kind, $value = null, $params = []) {
		$check = ['kind' => $kind, 'value' => $value];
		if ( !empty($params) ) {
			$check = array_merge(array_filter($params), $check);
		}
		$this->checks[] = $check;
		return $this;
	}

	protected function findFirstCheck($kind) {
		foreach ($this->checks as $check) {
			if ( $check['kind'] === $kind ) {
				return $check;
			}
		}
		return null;
	}

	protected function getFirstCheckValue($kind, $defaultResult = null) {
		$check = $this->findFirstCheck($kind);
		if ( $check === null ) {
			return $defaultResult;
		}
		return array_key_exists('value', $check) ? $check['value'] : $defaultResult;
	}
}