Download the PHP package eclipxe/micro-catalog without Composer

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

eclipxe/micro-catalog

Source Code Latest Version Software License Build Status Scrutinizer Coverage Status Total Downloads

Micro catalog PHP template class, useful to create value objects based on a known small catalog.

Several times I have the need for a catalog, by example, when receiving a result code and correlate to specific related values. This library helps me to resolve this common problem, and it may help you too.

Installation

Use composer, install using:

Usage

MicroCatalog is a template class, so you need to extend it to use it. Strictly speaking, you only need to implement two abstract methods: getEntriesArray(): array and getEntryValueOnUndefined(): mixed.

The sugar lives on is<Type>(): bool and get<Property>(): bool, with the special case of isUndefined(): bool. The is<Type>() methods allow to distinct a type by its index. The get<Property>() methods allow to get a string key from the value array when it has content.

See the following examples:

MicroCatalog example

Undefined entry

When creating an instance of MicroCatalog, when the key isn't found in the list of known values it will use the value from getValueOnUndefined().

If you don't want to allow unknown instances you can override and throw an exception on getValueOnUndefined().

Check if instance is of certain entry

Use the methods is<name>() to compare to specific value.

It will work by default when the indexes are strings, in example: isFoo() will evaluate if the current index is foo (with the first character as lower case).

You can redefine whits behavior by overriding the getEntryId(): string function. So isFoo() will compare foo with the returned value of getEntryId(): string.

You have to define these methods in your docblock to let your IDE or code analyzer detect what you are doing.

Get a magic property

If your known values array constains an array with string keys or a standard object with public variables then getSomething() will return what is defined on something key/property.

Even when PHP supports method with different case, this class use exact case, so getSomething() is different from getSomeThing(). The only transformation made to locate the key/property is to lower first char, then getSomething() will look up for something into local value. Anyhow, you can override the method getEntryValueWithKey(string $key): mixed to perform other transformation on key/property name.

Extending

I recommend you to declare your MicroCatalog classes as final to disable extension.

When creating a MicroCatalog extending from other, the parent MicroCatalog have priority on indices and values. You cannot override indices or values of previous classes.

Exceptions

Exceptions thrown from this package implements the empty interface Eclipxe\MicroCatalog\Exceptions\MicroCatalogException.

Creational patterns

You can write other creational patterns, the implemented constructor uses the value as index entry. If you want to create an entry based on some value or other type of evaluation I don't recommend to you to override the constructor, instead you can use static method calls.

PHP Support

This library is compatible with at least the oldest PHP Supported Version with active support. Please, try to use PHP full potential.

We adhere to Semantic Versioning. We will not introduce any compatibility backwards change on major versions.

Internal classes (using @internal annotation) are not part of this agreement as they must only exist inside this project. Do not use them in your project.

Contributing

Contributions are welcome! Please read CONTRIBUTING for details and don't forget to take a look in TODO and CHANGELOG files.

Copyright and License

The eclipxe/micro-catalog library is copyright © Carlos C Soto and licensed for use under the MIT License (MIT). Please see LICENSE for more information.


All versions of micro-catalog with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 eclipxe/micro-catalog contains the following files

Loading the files please wait ....