PHP Classes


Recommend this page to a friend!
  Classes of Axel Pardemann  >  PHP Primitive Types Class  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Primitive Types Class
Manipulate PHP primitive value types as objects
Author: By
Last change:
Date: 3 years ago
Size: 4,116 bytes


Class file image Download

<div align="center"> <img src=".assets/prim-logo.png"> <p align="center">

<a href=""><img alt="Build Status" src=""></a>
<a href=""><img alt="PHP Version" src=""></a>
<a href=""><img alt="Stable Release" src=""></a>
<a href=""><img src="" /></a>
<a href=""><img src="" /></a>
<a href=""><img alt="Total Downloads" src=""></a>
<a href=""><img alt="GitHub" src=""></a>

</p> </div> <hr>

PHP Prim is a PHP library that exposes primitive object data types for your convenience.


>Requirements: >- PHP 7.3+ >- BC Math extension (for UUIDs) >- JSON extension >- Multibyte String extension

Install Prim using Composer:

composer require norse-blue/prim


There are three ways to create a primitive object data type instance

  1. Using the `new` keyword:

    use NorseBlue\Prim\Scalars\StringObject as Str;
    $str = new Str('my string');
    echo $str->upper();
    // Outputs:
    // MY STRING
  2. Using the facades:

    _Note: params passed by reference are not supported in facades because the calls depend on `__callStatic`, which does not pass params by reference. See [Overloading][php_overloading_url]._

    use NorseBlue\Prim\Facades\Scalar\StringFacade as Str;
    echo Str::upper('my string');
    // Outputs:
    // MY STRING
  3. Using the namespaced functions:

    use NorseBlue\Prim\string;
    $str = string('my string');
    echo $str->upper();
    // Outputs:
    // MY STRING

You can also chain methods together:

use NorseBlue\Prim\string;

$str = string('THIS IS MY TEXT.')->lower()->ucfirst();
echo $str;

// Outputs:
// This is my text.

You don't need to worry about side-effects, as the objects are immutable and each function returns a new immutable object, so to store the value don't forget to assign it to a variable.


For the full documentation refer to the docs folder.


Please refer to the file for more information about what has changed recently.


Contributions to this project are accepted and encouraged. Please read the file for details on contributions.



If you discover any security related issues, please email instead of using the issue tracker.

Support the development

Do you like this project? Support it by donating

<a href="">

<img src=".assets/buy-me-a-coffee.svg" width="180" alt="Buy me a coffee" />



PHP Prim is open-sourced software licensed under the MIT license.


For more information send a message to info at phpclasses dot org.