PHP Classes

File: src/Motifs/paragonie/airship-classic/config_filter.php

Recommend this page to a friend!
  Classes of Scott Arciszewski   CMS Airship   src/Motifs/paragonie/airship-classic/config_filter.php   Download  
File: src/Motifs/paragonie/airship-classic/config_filter.php
Role: Example script
Content type: text/plain
Description: Example script
Class: CMS Airship
Content management system with security features
Author: By
Last change: Remaining code artefacts
Date: 6 years ago
Size: 2,721 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

use
ParagonIE\Ionizer\Filter\{
   
BoolFilter,
   
FloatFilter,
   
IntFilter,
   
StringFilter
};
use
ParagonIE\Ionizer\GeneralFilterContainer;

$colorCallback = function ($input): int {
    if (
$input < 0 || $input > 255) {
        throw new \
TypeError();
    }
    return (int)
$input;
};
$alphaCallback = function ($input): float {
    if (
$input < 0.0 || $input > 1.0) {
        throw new \
TypeError();
    }
    return (float)
$input;
};

/**
 * @return $motifInputFilter
 */
$motifInputFilter = (new GeneralFilterContainer())
    ->
addFilter(
       
'motif_config.bridge.gradient',
        new
BoolFilter()
    )
    ->
addFilter(
       
'motif_config.hull.background.enabled',
        new
BoolFilter()
    )
    ->
addFilter(
       
'motif_config.hull.background.tile',
        new
BoolFilter()
    )
    ->
addFilter(
       
'motif_config.hull.background.image',
        new
StringFilter()
    )
    ->
addFilter(
       
'motif_config.hull.background.shade.red',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.background.shade.green',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.background.shade.blue',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.background.shade.alpha',
        (new
FloatFilter())
            ->
addCallback($alphaCallback)
    )
    ->
addFilter(
       
'motif_config.hull.footer.override',
        new
BoolFilter()
    )
    ->
addFilter(
       
'motif_config.hull.footer.html',
        new
StringFilter()
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.enabled',
        new
BoolFilter()
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.background-image',
        new
StringFilter()
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.font.red',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.font.green',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.font.blue',
        (new
IntFilter())
            ->
addCallback($colorCallback)
    )
    ->
addFilter(
       
'motif_config.hull.blog-header.color',
        (new
StringFilter())
            ->
addCallback(
                function (
$input) {
                    if (!\
preg_match('/^[0-9A-Fa-f]{3,6}$/', $input)) {
                        return
null;
                    }
                    return
$input;
                }
            )
            ->
setDefault('181818')
    )
;