Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 20, 2024 via composer

webmozart/assert 1.10.0

Assertions to validate method input/output with nice error messages.
Package summary
Share
0
issues
1
license
2
MIT
Package created
11 Mar 2015
Version published
9 Mar 2021
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
symfony/polyfill-ctype@v1.29.0
webmozart/assert@1.10.0
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

1
All Dependencies CSV
β“˜ This is a list of webmozart/assert 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
symfony/polyfill-ctypev1.29.0-MIT
prod

Visualizations

Frequently Asked Questions

What does webmozart/assert do?

Webmozart/assert is a powerful PHP library that facilitates the validation of input and output in your methods. This library consists of efficient assertions for PHP that can greatly simplify your coding process while enhancing your application's safety. The library provides detailed and user-friendly error messages when validation fails, which aids immensely in debugging and error handling.

How do you use webmozart/assert?

The usage of Webmozart/assert is straightforward and follows a unique pattern that promotes readability and simplicity. To use Webmozart/assert in your PHP application, you firstly need to install it through composer in your application's directory:

composer require webmozart/assert

Once the library is installed, you can use its assertions in your classes by importing the Assert class and using its static methods to check your data. For instance:

use Webmozart\Assert\Assert;

class Employee
{
    public function __construct($id)
    {
        Assert::integer($id, 'The employee ID must be an integer. Got: %s');
        Assert::greaterThan($id, 0, 'The employee ID must be a positive integer. Got: %s');
    }
}

In this example, the class for an employee asserts the employee id to be an integer and positive. If these conditions are not met, Assert will throw an InvalidArgumentException with descriptive error messages.

Where are the webmozart/assert docs?

The documentation for the Webmozart/assert is included in the README file of its Git repository. The document provides a comprehensive overview of the features offered by the library, complete with a list of all assertions available in the Assert class. Each assertion is clearly defined and described, allowing developers to easily find and understand the one they need.