Download the PHP package tbpixel/type-adapter without Composer

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

Type Adapter

Latest Version on Packagist Build Status

A type-safe package for adapting from one data type to another.

Contents

Installation

Via composer:

Purpose

Have you ever needed to convert one instance (usually a data transfer object) from one type to another? I found myself writing static constructors like:

In all honesty this is fine for a start, but it really creates tight coupling between objects in order to handle these constructor conversions. If I wanted to remove Foo entirely, I'd have to go and find every place where I called fromFoo on the Bar class! This can get even worse if the source type comes from a package; it may become critical to decouple this package from an application and yet references to it are now litered all through out my application.

This why I created the Type Adapter package. This package allows for loosely coupled, type safe conversions without static constructors. It attempts to reduce coupling and act as a communcation converter between the layers of your application. It is particularly useful in hexagonal architected, and by extension domain driven application, software design.

Examples

Taking the types from above, we could create an adapter that converts from Foo to Bar like so:

You can see a couple of things going on here. For starters, we implement the Adaptable interface defined in this package. This interface requires us to implement an adapt($resource) method and a expects() method.

The adapt method accepts in the resource, which we can type hint using a doc block comment, and then returns the converted type.

The expects method is for type safety. It defines out a validation rule for the adapt method to expect. This is what allows us type safety.

The expects method can either return a string type name or an array of strings, for variadic types.

Contributing

Please see CONTRIBUTING for details.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Support Me

Hi! I'm a developer living in Vancouver, BC and boy is the housing market tough. If you wanna support me consider following me on Twitter @TBPixel, or maybe buying me a coffee. Thanks!

License

The MIT License (MIT). Please see License File for more information.


All versions of type-adapter with dependencies

PHP Build Version
Package Version
Requires php 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 tbpixel/type-adapter contains the following files

Loading the files please wait ....