Download the PHP package eonx-com/easy-utils without Composer

On this page you can find all versions of the php package eonx-com/easy-utils. 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 easy-utils

---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---

EasyUtils

This package provides helper classes.

Require package (Composer)

The recommended way to install this package is to use Composer:

Helper list

CollectorHelper

The Collector Design Pattern is a great method for keeping your code SOLID. However, using it in multiple parts of your project can lead to significant repetition. The main purpose of the CollectorHelper is to prevent duplicated code and facilitate implementation of the Collector Design Pattern in your project.

Most popular PHP frameworks provide features to tag services, and then define all services for a specific tag as dependencies to other services. See the following resources for examples:

Those features help you implement the Collector Design Pattern in your project because they allow you to easily inject a collection of services sharing the same tag into other services.

However, there are some things you need to consider:

Let's elaborate on the above points.

No guarantee on the content of tagged services

The service tagging features do not allow you to ensure all services sharing the same tag meet common criteria. Symfony has a feature to automatically tag services based on their class, but nothing stops you from manually tagging a service with the same tag or even one of your dependencies.

This is why we strongly recommend you always filter the given iterable of services by a given class/interface of your choice by using the filterByClass() or filterByClassAsArray() methods of the CollectorHelper.

No control on the order the services are organised

When using service tagging features, you can control the order that the services are organised by simply changing the order in which you define the services. However, as above, there is nothing stopping you or one of your dependencies from tagging a service with the same tag. Therefore, you cannot guarantee the order as you cannot modify the dependencies' service definitions. But the CollectorHelper can help us!

In some cases, the order of the given services does not matter, so there is no need to do anything. But if your logic requires the services be used in a specific order, then use the orderHigherPriorityFirst() and/or orderLowerPriorityFirst() methods!

These methods will sort the objects within the given iterable based on their priority. In order to define an object's priority, it must implement the EonX\EasyUtils\Common\Helper\HasPriorityInterface provided by this package. If an object doesn't implement this interface then its priority will default to 0 automatically.

CollectorHelper::convertToArray()

The convertToArray() method will convert any iterable to a simple PHP array. It is useful when you want to use array methods on an iterable.

For a simple example of when to use the convertToArray() method, imagine you have a class which accepts an iterable of "workers" in its constructor. To safely use these "workers", you want to ensure each of them implements the right interface, so you filter them to keep only the "good workers" by using the array_filter() function. If the "workers" were already an array, then there would be no problem. However, because they are defined as iterable, you cannot guarantee you will receive an array. So use the convertToArray() method!

CollectorHelper::filterByClass()

The use case of filtering by class (used above to explain the convertToArray() method) is very common (at least in our projects :smiley: ), which is why CollectorHelper provides the filterByClass() method to do it for you.

The following example is the same as for the convertToArray() method above. If you have an iterable and you want to ensure each item is an instance of a specific class/interface, use the filterByClass() method!

::: tip The filterByClass() method still returns an iterable (or, more precisely, a generator). If you need an array, you can use the filterByClassAsArray() method instead. :::

CollectorHelper::filterByClassAsArray()

This method is similar to the filterByClass() method, but with a little tweak. If you have an iterable and you want to make sure each item is an instance of a specific class/interface, but you need the output to be an array, use the filterByClassAsArray() method!

CollectorHelper::ensureClass() and CollectorHelper::ensureClassAsArray()

Those methods are similar to the filterByClass() and filterByClassAsArray() methods, however they will throw an exception if at least of the items is not an instance of the given class.

::: warning Please note that with the ensureClass() method, the exception will be thrown only when iterating through the generator. :::

CollectorHelper::orderHigherPriorityFirst()

The orderHigherPriorityFirst() method will ensure the object with the highest priority is placed first, and the object with the lowest priority is placed last.

In order to define an object's priority, it must implement the EonX\EasyUtils\Common\Helper\HasPriorityInterface provided by this package. If an object doesn't implement this interface then its priority will default to 0 automatically.

::: tip The orderHigherPriorityFirst() method still returns an iterable (or, more precisely, a generator). If you need an array, you can use the orderHigherPriorityFirstAsArray() method instead. :::

CollectorHelper::orderLowerPriorityFirst()

The orderLowerPriorityFirst() method is the opposite of orderHigherPriorityFirst(). It will ensure the object with the lowest priority is placed first, and the object with the highest priority is placed last.

In order to define an object's priority, it must implement the EonX\EasyUtils\Common\Helper\HasPriorityInterface provided by this package. If an object doesn't implement this interface then its priority will default to 0 automatically.

::: tip The orderLowerPriorityFirst() method still returns an iterable (or, more precisely, a generator). If you need an array, you can use the orderLowerPriorityFirstAsArray() method instead. :::

Math

The Math helper provides the following methods:


All versions of easy-utils with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-bcmath Version *
ext-ctype Version *
ext-filter Version *
symfony/config Version ^7.1
symfony/dependency-injection Version ^7.1
symfony/http-kernel Version ^7.1
symfony/string Version ^7.1
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 eonx-com/easy-utils contains the following files

Loading the files please wait ....