PHP Classes

File: src/DataTypes/Text.php

Recommend this page to a friend!
  Packages of Amirreza Ebrahimi   HeroQR Powerful PHP QR Code Library to generate PNG, SVG, PDF, Logos Ready to Use with Laravel   src/DataTypes/Text.php   Download  
File: src/DataTypes/Text.php
Role: Class source
Content type: text/plain
Description: Class source
Class: HeroQR Powerful PHP QR Code Library to generate PNG, SVG, PDF, Logos Ready to Use with Laravel
Generate QR code images in several formats
Author: By
Last change: Update of src/DataTypes/Text.php
Date: 6 months ago
Size: 809 bytes
 

Contents

Class file image Download
<?php

namespace HeroQR\DataTypes;

use
HeroQR\Contracts\DataTypes\AbstractDataType;

/**
 * Class Text
 *
 * This class validates plain text to ensure it does not contain any unsafe content.
 * It checks the text for common security vulnerabilities, specifically:
 * - Script tags (to prevent XSS attacks).
 * - SQL injection patterns (to prevent malicious database queries).
 *
 * If any of these vulnerabilities are detected, the text is considered invalid.
 *
 * Example of usage:
 * Text::validate("Sample text here");
 *
 * @package HeroQR\DataTypes
 */

class Text extends AbstractDataType
{
    public static function
validate(string $value): bool
   
{
        if (
self::hasScriptTag($value) || self::hasSqlInjection($value)) {
            return
false;
        }

        return
true;
    }
}