PHP 7.4.33
Preview: NeedsTrait.php Size: 1.06 KB
/home/godevadmin/www/admin/vendor/aws/Aws/Crypto/Polyfill/NeedsTrait.php

<?php
namespace Aws\Crypto\Polyfill;

use Aws\Exception\CryptoPolyfillException;

/**
 * Trait NeedsTrait
 * @package Aws\Crypto\Polyfill
 */
trait NeedsTrait
{
    /**
     * Preconditions, postconditions, and loop invariants are very
     * useful for safe programing.  They also document the specifications.
     * This function is to help simplify the semantic burden of parsing
     * these constructions.
     *
     * Instead of constructions like
     *     if (!(GOOD CONDITION)) {
     *         throw new \Exception('condition not true');
     *     }
     *
     * you can write:
     *     needs(GOOD CONDITION, 'condition not true');
     * @param $condition
     * @param $errorMessage
     * @param null $exceptionClass
     */
    public static function needs($condition, $errorMessage, $exceptionClass = null)
    {
        if (!$condition) {
            if (!$exceptionClass) {
                $exceptionClass = CryptoPolyfillException::class;
            }
            throw new $exceptionClass($errorMessage);
        }
    }
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
7.06 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
7.09 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
6.40 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.80 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download
1.06 KB lrwxrwxr-x 2024-06-18 20:10:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).