Download the PHP package adaddinsane/dataobject without Composer

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

Data Object

This package provides two extendable classes for accessing the contents of a data array through various default and custom methods.

Why would you do this? The main reason is that simply passing arrays gives you no validation of what is being passed, but an array as an object can be type-hinted so provide better certainty of correct code.

All classes are abstract (which is ignored in the examples below) and must be extended in order to be used.

Options

One class allows the data to be written, while the other provides an immutable object which has no set() method.

This package can be used in conjunction with the ParamVerify package that can check the contents of an array before creating the data object.

How to use

You could just use these classes as they stand but that's not the best way.

Let's say you fetch data from an API in the form of an array, we'll call it personData. To use the DataObject with that you'd create a new class:

You can create methods to extract precisely the data you need.

And if the API data structure changes, you just change the class to match. If you use getFullName() in multiple places, you only need to change it once.

You can now type-hint in arguments to ensure you're delivering the right item.

GenericBag

This is a third abstract object which extends a DataObject to allow the items being added to be verified as being of a specific class type or types.

The verification function can also be overridden if something other than classes are being stored.

The point of a Bag is that you can have a collection of items which can be passed around together, and can be type-hinted to ensure the right items are being delivered.

Merge

In your GenericBag class, implement the GenericBagMergeInterface class and trait GenericBagMergeTrait; you then have access to a merge() method which takes another GenericBag object as a parameter.

Filter

In your GenericBag class, implement the GenericBagFilterInterface class and trait GenericBagFilterTrait; you then have access to a filter() method which takes a filter callable.

The filter callable is used in an array_filter() command on the GenericBag's data to extract a subset of items which is then used to create and return a new GenericBag of the same class.

Sort

In your GenericBag class, implement the GenericBagSortInterface class and trait GenericBagSortTrait; you then have access to a sort() method which takes a sort callable.

The sort callable is used in an uasort() command on the GenericBag's data which sorts the items of this GenericBag. No value is returned.

Other forms of access

The DataObjects also implement the ArrayIterator and Count interfaces, which means that if you want to you can use the object in a loop or count the values.


All versions of dataobject with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 adaddinsane/dataobject contains the following files

Loading the files please wait ....