2017 © Pedro Peláez
 

library lang

Lang package implementation providing basic PHP datatypes.

image

techdivision/lang

Lang package implementation providing basic PHP datatypes.

  • Wednesday, April 8, 2015
  • by wagnert
  • Repository
  • 9 Watchers
  • 2 Stars
  • 3,082 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 11 % Grown

The README.md

TechDivision_Lang

Latest Stable Version Total Downloads Latest Unstable Version License Build StatusScrutinizer Code QualityCode Coverage, (*1)

Introduction

This package provides implementation of basic PHP datatypes., (*2)

Installation

If you want to use the library with your application you can install it by adding, (*3)

{
    "require": {
        "techdivision/lang": "dev-master"
    },
}

to your composer.json and invoke composer update in your project., (*4)

Usage

This package provides classes representing an object oriented implementation for some basic datatypes., (*5)

As there has been (and still are) many discussions about PHP and type safety i decided to implement a small, really basic library that will offer the most basic datatype needed in nearly every project. To be honest, i really like almost allof those nice possibilities languages like Java provides, but as PHP is not Java, you always have to find a neat way for implementing similar things in a way it makes sense in a PHP environment., (*6)

The intention for implementing that classes was the possiblity to make your critical functions and methods type safe, by using them for type hints on the one hand and the possiblity to have an quick and easy to use kind of data validation mechanism on the other., (*7)

As you may know, using type hints will probably slow down your code a bit, so take care when you use them and always have an eye on possible performance impacts by running performance tests regularily., (*8)

The data type implementations this library will provide, are, (*9)

  • Object
  • Boolean
  • Integer
  • Float
  • String

The following examples wil give you a short introduction about the functionality each class will provide and how you can use it in your code. Please be aware, that the examples are not intended to make any sense, they should only give you an idea what is possible., (*10)

Object

The abstract class Object implements a low level presentation of a class. All other classes of this library use it as superclass., (*11)

Boolean

Using a Boolean instance to compare against anonther one or try to instanciate it with a not boolean value., (*12)

// initialize a new Integer instance
$bool = new Boolean(true);
$bool->equals(new Boolean(false)); // false

// throws a ClassCastException
$invalid = new Boolean('aValue');

Integer

Here are some examples how you can use the Integer class, (*13)

// initialize a new Integer instance
$int = new Integer(17);

// get the float value of the Integer
echo $int->floatValue() . PHP_EOL; // 17.0
echo $int->stringValue() . PHP_EOL; // '17'

// check that the two Integer instances are equal
$int->equals(Integer::valueOf(new String('17'))); // true

Float

The example for using a Float shows you how to add to instances and print the float value, (*14)

// initialize a new Float instance
$float = new Float(10.005);
$float->add(new Float(10.105));

// check the value
echo $float->floatValue() . PHP_EOL; // 20.11

String

To show you how you can use the String class we'll simple concatenate to instances, (*15)

// initialize a new String instance
$string = new String('value to');

// check that String was successfully concatenated
echo $string->concat(new String(' search')) . PHP_EOL; // 'value to search'

Yeah, this are really simple examples, and as i told you before in most cases i'll use that classes for simple things like type hints and so on., (*16)

If you like to use that stuff also, feel free to implement your own types and send me a pull request :), (*17)

External Links

The Versions

08/04 2015

dev-master

9999999-dev https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

27/10 2014

0.1.9

0.1.9.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

25/10 2014

0.1.8

0.1.8.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

15/09 2014

0.1.7

0.1.7.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

15/09 2014

0.1.6

0.1.6.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

14/09 2014

0.1.5

0.1.5.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

 

The Development Requires

basic datatypes objects boolean string float integer

09/09 2014

0.1.4

0.1.4.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

basic datatypes objects boolean string float integer

08/09 2014

0.1.3

0.1.3.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

basic datatypes objects boolean string float integer

03/09 2014

0.1.2

0.1.2.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

basic datatypes objects boolean string float integer

25/07 2014

0.1.1

0.1.1.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

  • php >=5.4.0

 

The Development Requires

basic datatypes objects boolean string float integer

11/07 2014

0.1.0

0.1.0.0 https://github.com/techdivision/TechDivision_Lang

Lang package implementation providing basic PHP datatypes.

  Sources   Download

OSL-3.0

The Requires

  • php >=5.4.0