Download the PHP package laragear/compare without Composer

On this page you can find all versions of the php package laragear/compare. 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 compare

Modern PHP has very flexible Comparison Operators, so this package is no longer needed.


Comparable

Latest Version on Packagist Latest stable test run Codecov coverage CodeClimate Maintainability Sonarcloud Status Laravel Octane Compatibility

Small utility trait to fluently compare object values.

Become a sponsor

Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can spread the word!

Requirements

Installation

Fire up Composer and require this package in your project.

composer require laragear/comparable

That's it.

Usage

Add the Comparable trait to your object, and that's it. You can start a comparison using is() with the key name, unless you want to compare the whole object.

Once done, you can start a comparison using is().

When not issuing a key, the whole object will be used to compare.

Behind the scenes, it uses data_get() from Laravel helpers to retrieve the values from your object using "dot" notation.

To negate a condition, just issue not(), or the not property.

Available conditions

aboveZero equalOrGreaterThan lessThan
belowZero equalOrLessThan null
between exactly true
blank false truthy
containing falsy zero
containingOneItem filled
counting greaterThan

aboveZero()

Checks if a numeric value is above zero.

belowZero()

Checks if a numeric value is below zero.

between()

Check if the numeric value is between two numbers.

Issuing false as third parameter will make the comparison exclusive.

blank()

Check if the value is "blank".

counting()

Checks if a list contains the exact number of items.

containing()

Checks if a string contains a string, or a list contains an item.

containingOneItem()

Check if the value is a list and contains only one item.

equalOrGreaterThan()

Check that a numeric value, or the value list count, is equal or greater than a number.

exactly()

Check that a value is exactly the value given, strictly.

false()

Check if a value is exactly false.

falsy()

Check if a value evaluates to false.

equalOrLessThan()

Check that a numeric value, or the value list count, is equal or less than a number.

filled()

Check if the value is "filled".

greaterThan()

Check if the numeric value, or the list items count, is greater than the issued number,

lessThan()

Check if the numeric value, or the list items count, is less than the issued number,

null()

Check if the value is null.

true()

Check if a value is exactly true.

truthy()

Check if a value evaluates to true.

zero()

Check if the numeric value, or the list items count, is exactly zero.

Higher Order Comparisons

You can access to a comparison result using dynamic properties:

$object->blank $object->false $object->aboveZero
$object->filled $object->falsy $object->belowZero
$object->true $object->null $object->containingOneItem
$object->truthy $object->zero

Laravel Octane compatibility

There should be no problems using this package with Laravel Octane.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

This specific package version is licensed under the terms of the MIT License, at time of publishing.

Laravel is a Trademark of Taylor Otwell. Copyright © 2011-2022 Laravel LLC.


All versions of compare with dependencies

PHP Build Version
Package Version
Requires php Version 8.*
illuminate/support Version 9.*|10.*
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 laragear/compare contains the following files

Loading the files please wait ....