Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 19, 2024 via composer

beberlei/assert v3.3.2

Thin assertion library for input validation in business models.
Package summary
Share
0
issues
1
license
1
BSD-2-Clause
Package created
20 May 2012
Version published
16 Dec 2021
Maintainers
1
Total deps
1
Direct deps
0
License
BSD-2-Clause

Issues

0
This package has no issues

Licenses

BSD 2-Clause "Simplified" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
beberlei/assert@v3.3.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of beberlei/assert 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does beberlei/assert do?

Beberlei/assert is a lightweight PHP library that provides a set of assertions and guard methods for input validation in business-model, libraries, and application low-level code. It is not designed for filtering but rather serves as a practical tool for implementing pre- and post-conditions on input data in your code. The motivation behind this library is to simplify the code paths for asserting conditions while reducing the amount of written code. When an assertion fails, an exception is thrown which prevents the necessity for if-clauses in your code.

How do you use beberlei/assert?

To use beberlei/assert, you will first need to install it via Composer with the command:

composer require beberlei/assert

After the installation, you can use the library in your PHP files like so:

<?php
use Assert\Assertion;

function duplicateFile($file, $times)
{
    Assertion::file($file);
    Assertion::digit($times);

    for ($i = 0; $i < $times; $i++) {
        copy($file, $file . $i);
    }
}

In this example, the Assertion::file($file) call checks whether $file exists as a file and Assertion::digit($times) verifies the $times value to be a digit. If any of these conditions are not met, an exception is thrown.

For more complex scenarios, beberlei/assert provides the "NullOr" and "All" helpers methods to check if a value is null OR succeeds for the assertion and to verify if all provided values hold for the assertion respectively.

Where are the beberlei/assert docs?

As of the nature of SEO for developer libraries and tools, technical documentation is crucial for effective SEO performance. The beberlei/assert documentation details can be found on its GitHub page. There you'll find comprehensive information about installation, usage examples, list of assertions, exception and error handling, customised exception messages, and details on how to contribute to the project.