codekandis/converters

`codekandis/converters` is a library providing uni- and bi-directional converter interfaces and classes.

1.0.0 2024-05-23 00:03 UTC

This package is auto-updated.

Last update: 2024-05-23 00:05:06 UTC


README

Version License Minimum PHP Version Code Coverage

codekandis/converters is a library providing converter interfaces and classes.

Index

Installation

Install the latest version with

$ composer require codekandis/converters

How to use

Unidirectional converters

$value = false;

( new IntegerToBinaryStringUniDirectionalConverter() )
    ->convert( $value );
/**
 * 0
 */

$value = 0;

( new BinaryStringToIntegerUniDirectionalConverter() )
    ->convert( $value );
/**
 * false
 */

Bidirectional converters

$value = 42;

( new IntegerToBinaryStringBiDirectionalConverter() )
    ->convertTo( $value );
/**
 * '101010'
 */

$value = '101010';

( new IntegerToBinaryStringBiDirectionalConverter() )
    ->convertFrom( $value );
/**
 * 42
 */

List of converters

See the documentation for further information about all available base and concreate converters.