Download the PHP package exeque/fluent-assert without Composer

On this page you can find all versions of the php package exeque/fluent-assert. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fluent-assert

Fluent Assert

This library is built upon webmozart/assert and provides a fluent interface for assertions, which allows for a more compact set of assertions on the same value.

It is a useful tool for those who want to use webmozart/assert but prefer a more fluent interface.

Built with love ❤️

Installation

Use Composer to install the library.

Differences

There are a few differences between this library and webmozart/assert:

Example

The example from webmozart/assert can be rewritten as:

Grouped Assertions

The fluent interface provides a and() and or() method to group assertions.

This is useful when you want to make multiple assertions at once and a singular combined error.

Iterative Assertions

The each() method allows you to iterate over an array or an ArrayAccess object and apply assertions to each value.

The errors thrown will have a prefix of failing index applied.

The IndexedInvalidArgumentException can provide the index that failed use getIndex() and the original message using getOriginalMessage().

Positional Assertions

The at() method allows you to assert a value at a specific index in an array or an ArrayAccess object.

It automatically calls keyExists() on the index before applying the assertion.

The errors thrown will have a prefix of failing index applied.

Conditional Assertions

Sometimes you only want to apply certain assertions if a condition is met or not. The when() method allows you to do this.

Inverted Assertions

The not() method allows you to invert the assertion. This is useful when the assertions MUST fail.

Assertions

All assertions from webmozart/assert are available. See here

An extended implementation of webmozart/assert is available in the ExeQue\FluentAssert\Base class.

The following additional assertions are available:

Method Description
hasIndices($value, string $message = '') Check that a value has indices (array or ArrayAccess)
arrayContains($array, mixed $value, string $message = '') Check that a value contains another value
type($value, string $type, string $message = '') Check that a value is of a certain type (using get_debug_type())
publicPropertyExists($value, string $name, string $message = '') Check that a value has a public property
protectedPropertyExists($value, string $name, string $message = '') Check that a value has a protected property
privatePropertyExists($value, string $name, string $message = '') Check that a value has a private property
staticPropertyExists($value, string $name, string $message = '') Check that a value has a static property
instancedPropertyExists($value, string $name, string $message = '') Check that a value has an instanced property

Development

The library uses code generation to create definitions for all methods present in webmozart/assert.

To trigger the generation run:

Testing

You can run the tests using the following command:

License

This library is open-sourced software licensed under the MIT license.

Appreciation

Big thanks to Bernard Schussek (and community) for the webmozart/assert.

It is one of the first dependencies I include in any project and I use it extensively.


All versions of fluent-assert with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
webmozart/assert Version ^1.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package exeque/fluent-assert contains the following files

Loading the files please wait ....