| Server IP : 54.36.91.62 / Your IP : 216.73.217.117 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/voscatalogues/libraries/fof40/Model/Mixin/ |
Upload File : |
<?php
/**
* @package FOF
* @copyright Copyright (c)2010-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace FOF40\Model\Mixin;
defined('_JEXEC') || die;
use Joomla\CMS\Language\Text;
use RuntimeException;
/**
* Trait for check() method assertions
*/
trait Assertions
{
/**
* Make sure $condition is true or throw a RuntimeException with the $message language string
*
* @param bool $condition The condition which must be true
* @param string $message The language key for the message to throw
*
* @throws RuntimeException
*/
protected function assert($condition, $message)
{
if (!$condition)
{
throw new RuntimeException(Text::_($message));
}
}
/**
* Assert that $value is not empty or throw a RuntimeException with the $message language string
*
* @param mixed $value The value to check
* @param string $message The language key for the message to throw
*
* @throws RuntimeException
*/
protected function assertNotEmpty($value, $message)
{
$this->assert(!empty($value), $message);
}
/**
* Assert that $value is set to one of $validValues or throw a RuntimeException with the $message language string
*
* @param mixed $value The value to check
* @param array $validValues An array of valid values for $value
* @param string $message The language key for the message to throw
*
* @throws RuntimeException
*/
protected function assertInArray($value, array $validValues, $message)
{
$this->assert(in_array($value, $validValues), $message);
}
/**
* Assert that $value is set to none of $validValues. Otherwise throw a RuntimeException with the $message language
* string.
*
* @param mixed $value The value to check
* @param array $validValues An array of invalid values for $value
* @param string $message The language key for the message to throw
*
* @throws \RuntimeException
*/
protected function assertNotInArray($value, array $validValues, $message)
{
$this->assert(!in_array($value, $validValues, true), $message);
}
}