2017 © Pedro Peláez
 

library component_data_type

php component data type

image

net_bazzline/component_data_type

php component data type

  • Wednesday, June 18, 2014
  • by artodeto
  • Repository
  • 1 Watchers
  • 0 Stars
  • 55 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP Component - Data Type

This component includes class definitions for php basic data types like:, (*1)

  • Boolean
  • Floating point
  • Integer
  • String
  • Numeric
  • DataArray

By using this component, you are able to use type hints also for basic data types., (*2)

The build status of the current master branch is tracked by Travis CI: Build Status, (*3)

Features

  • Enables type hints for basic php types
  • Types shipped with useful methods
  • Are comparable with native php types by using "=="
  • Provides generic type casting by implemented "toString()" methods (and so on)
  • Provides type migration by from and to methods

Usage

Example

/**
 * Class with type hint for string
 *
 * @author stev leibelt <artodeto@arcor.de>
 * @since 2013-08-04
 */
class MyClass
{
    /**
     * @var array
     * @author stev leibelt <artodeto@arcor.de>
     * @since 2013-08-04
     */
    private $strings = array();

    /**
     * Super cool method with type hint for string
     *
     * @author stev leibelt <artodeto@arcor.de>
     * @since 2013-08-04
     */
    public function addString(\Net\Bazzline\Component\DataType\String $string)
    {
        $this->strings[] = $string;

        return $this;
    }
}

$myString = new \Net\Bazzline\Component\DataType\String('super cool test string');

$myClass = new MyClass();
$myClass->addString($myString);

Hints

  • Extend provided types with classes in own namespace.
  • If you add a super cool method to your type, push it and be a part of the development team

Install

Via Git

cd path/to/my/git/respositories
mkdir -p stevleibelt/php_component_data_type
cd stevleibelt/php_component_data_type

git clone git://github.com/stevleibelt/php_component_data_type.git .

Via Composer

require: "net_bazzline/component_data_type": "dev-master"

Why?

I started developing this component because of the many casts i have to do while dealing with php's basic data types. As general, i searched the web for existing and easy to use components but could not find them. If you find one, please tell me. Last but not least SplTypes are still experimental., (*4)

To Do

  • Cover existing unittest with validation of implemented interfaces
  • Can we use pack?
  • Add modulo to Numeric
  • Add locking (mark a value as read only)
  • Add Date type -> check Joda Time
  • Add Time type
  • Add DateTime type
  • Add arrayAccess to string
  • Add collection
  • Add examples
  • Add benchmarks
  • Option type?
  • Enum?
  • Add invoke to String?

Links

Following are links i found and used for creating this component., (*5)

Other Implementations

History

  • next
    • Coverd existing classes with "ableInterface" where each defines a from$Type and to$Type method
    • Started class for array called DataArray
    • Implemented usage of LockInterface, now you can lock a datatype to prevent from value changes
  • 1.1.0
    • Updated readme
    • Implemented isEmpty method which leads to different behaviour while creating an object
  • 1.0.0
    • Finished data type Boolean
    • Finished data type FloatingPoint
    • Finished data type Numierc
    • Finished data type Integer
    • Finished data type String

The Versions

18/06 2014

dev-master

9999999-dev https://github.com/stevleibelt/php_component_data_type

php component data type

  Sources   Download

LGPLv3

The Requires

 

The Development Requires

component php string number data type boolean float integer net_bazzline

04/08 2013

1.1.0

1.1.0.0 https://github.com/stevleibelt/php_component_data_type

php component data type

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

component php string number data type boolean float integer net_bazzline

04/08 2013

1.0.0

1.0.0.0 https://github.com/stevleibelt/php_component_data_type

php component data type

  Sources   Download

LGPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

component php string number data type boolean float integer net_bazzline