<?php

if(isset($_GET['show_source'])) {
    
show_source(__FILE__);
    die();
}

require_once(
'Enum.php');
require_once(
'Flags.php');

Class 
VehicleTypes extends Flags {
    const 
Sedan = 1;
    const 
Station = 2;
    const 
Mpv = 4;
    const 
Truck = 8;
    const 
Bike = 16;
    const 
Cabrio = 32;
}

class 
CrudActions extends Flags {
    const 
Add = 1;
    const 
Read = 2;
    const 
Edit = 4;
    const 
Remove = 8;
}

$allowedTypes = new VehicleTypes();

echo 
get_class($allowedTypes);
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes;
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes();
echo 
PHP_EOL . PHP_EOL;

$allowedTypes = $allowedTypes->add(VehicleTypes::Sedan())->add(VehicleTypes::Truck())->add(VehicleTypes::Truck())->add(VehicleTypes::Cabrio());

echo 
$allowedTypes;
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes();
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes->has(VehicleTypes::Station())? 'true': 'false';
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes->has(VehicleTypes::Truck())? 'true': 'false';
echo 
PHP_EOL . PHP_EOL;

$allowedTypes->remove(VehicleTypes::Truck());

echo 
$allowedTypes->has(VehicleTypes::Truck())? 'true': 'false';
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes;
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes->hasAll(VehicleTypes::Truck()->add(VehicleTypes::Cabrio()))? 'true': 'false';
echo 
PHP_EOL . PHP_EOL;

echo 
$allowedTypes->hasAny(VehicleTypes::Truck()->add(VehicleTypes::Cabrio()))? 'true': 'false';
echo 
PHP_EOL . PHP_EOL;

$test = CrudActions::Add()->Add(CrudActions::Edit());

echo 
$test;