2017 © Pedro Peláez
 

library wrappers

Wrapper types

image

xp-forge/wrappers

Wrapper types

  • Sunday, July 12, 2015
  • by thekid
  • Repository
  • 2 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Wrapper types

Build Status on TravisCI XP Framework Module BSD Licence Required PHP 5.4+ Supports PHP 7.0+ Required HHVM 3.4+ Latest Stable Version, (*1)

This API defines object-oriented API to base types., (*2)

API

package lang.types {
  public abstract class lang.types.Num
  public final class lang.types.Int8       // "Byte", -128 to 127
  public final class lang.types.Int16      // "Short", -32768 to 32767
  public final class lang.types.Int32      // "Int", -2^31 to (2^31)- 1
  public final class lang.types.Int64      // "Long", -2^63 to (2^63)- 1
  public final class lang.types.Single     // "Float", -3.4 x 10^38 to +3.4 x 10^38
  public final class lang.types.Double     // "Double", ±5.0 x 10^324 to ±1.7 x 10^308
  public final class lang.types.Str        // "String"
}

Strings

use lang\types\Str;

$greeting= new Str('Hello');

(string)$greeting;               // "Hello"
$greeting->length();             // 5

$greeting->startsWith('Hell');   // TRUE
$greeting->endsWith('lo');       // FALSE
$greeting->contains('ello');     // TRUE

$greeting->indexOf('e');         // 1
$greeting->lastIndexOf('l');     // 3
$greeting->indexOf('a');         // -1

$greeting->concat('World');      // Str("Hello World") - in a new instance

Unicode support is realized via either the mbstring or iconv libraries, whichever is available., (*3)

Numbers

use lang\types\Int8;
use lang\types\Int16;
use lang\types\Int32;
use lang\types\Int64;

$number= new Int32(6100);

(string)$number;                 // "6100"

$number->intValue();             // 6100
$number->doubleValue();          // 6100.0

new Int8(9999);                  // *** lang.IllegalArgumentException, out of range

64-bit support is realized via the bcmath extension on 32-bit platforms and versions of PHP., (*4)

use lang\types\Single;
use lang\types\Double;

$number= new Single(1.5);

(string)$number;                 // "1.5"

$number->intValue();             // 1
$number->doubleValue();          // 1.5
$number->round(0);               // 2.0

The Versions

12/07 2015

dev-master

9999999-dev http://xp-framework.net/

Wrapper types

  Sources   Download

BSD-3-Clause

The Requires

 

module xp

12/07 2015

v0.1.0

0.1.0.0 http://xp-framework.net/

Wrapper types

  Sources   Download

BSD-3-Clause

The Requires

 

module xp