rugk/xenforo-threema-gateway

View on GitHub
src/library/ThreemaGateway/Option/ThreemaGatewayId.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
/**
 * Threema Gateway ID option.
 *
 * @package ThreemaGateway
 * @author rugk
 * @copyright Copyright (c) 2016 rugk
 * @license MIT
 */

class ThreemaGateway_Option_ThreemaGatewayId
{
    /**
     * Verifies the Threema ID format.
     *
     * @param string             $threemaid  Input threema ID
     * @param XenForo_DataWriter $dataWriter
     * @param string             $fieldName  Name of field/option
     *
     * @return bool
     */
    public static function verifyOption(&$threemaid, XenForo_DataWriter $dataWriter, $fieldName)
    {
        /** @var mixed $error useless error var */
        $error = '';

        //check for formal errors
        if ($threemaid != '' && !ThreemaGateway_Handler_Validation::checkThreemaId($threemaid, 'gateway', $error, false)) {
            $dataWriter->error(new XenForo_Phrase('threemagw_invalid_threema_id'), $fieldName);
            return false;
        }

        return true;
    }
}