Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 51 | All time: 10,677 This week: 673 |
Version | License | PHP version | Categories | |||
php-prim 1.0.0 | MIT/X Consortium ... | 7.3 | Tools, Text processing, Data types, P..., T... |
Description | Author | |
This package can manipulate PHP primitive value types as objects. |
<div align="center"> <img src=".assets/prim-logo.png"> <p align="center">
<a href="https://circleci.com/gh/norse-blue/php-prim/tree/master"><img alt="Build Status" src="https://img.shields.io/circleci/project/github/norse-blue/php-prim/master.svg?color=%23a3be8c&style=popout-square"></a>
<a href="https://php.net/releases"><img alt="PHP Version" src="https://img.shields.io/packagist/php-v/norse-blue/prim.svg?color=%23b48ead&style=popout-square"></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="Stable Release" src="https://img.shields.io/packagist/v/norse-blue/prim.svg?color=%235e81ac&style=popout-square"></a>
<a href="https://codeclimate.com/github/norse-blue/php-prim/maintainability"><img src="https://api.codeclimate.com/v1/badges/51195ec3a47a8b071381/maintainability" /></a>
<a href="https://codeclimate.com/github/norse-blue/php-prim/test_coverage"><img src="https://api.codeclimate.com/v1/badges/51195ec3a47a8b071381/test_coverage" /></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/norse-blue/prim.svg?color=%235e81ac&style=popout-square"></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="GitHub" src="https://img.shields.io/github/license/norse-blue/php-prim.svg?color=%235e81ac&style=popout-square"></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
Using the `new` keyword:
use NorseBlue\Prim\Scalars\StringObject as Str;
$str = new Str('my string');
echo $str->upper();
// Outputs:
// MY STRING
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
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 CHANGELOG.md file for more information about what has changed recently.
Contributions to this project are accepted and encouraged. Please read the CONTRIBUTING.md file for details on contributions.
If you discover any security related issues, please email security@norse.blue instead of using the issue tracker.
Do you like this project? Support it by donating
<a href="https://www.buymeacoffee.com/axelitus">
<img src=".assets/buy-me-a-coffee.svg" width="180" alt="Buy me a coffee" />
</a>
PHP Prim is open-sourced software licensed under the MIT license.
[php_overloading_url]: https://www.php.net/manual/en/language.oop5.overloading.php
Files (144) |
File | Role | Description | ||
---|---|---|---|---|
.assets (2 files) | ||||
.changelog (3 files) | ||||
.circleci (1 file) | ||||
.github (4 files) | ||||
src (4 files, 7 directories) | ||||
tests (1 file, 3 directories) | ||||
.editorconfig | Data | Auxiliary data | ||
.phpcs.xml.dist | Data | Auxiliary data | ||
.styleci.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE.md | Lic. | License text | ||
phpstan.neon.dist | Data | Auxiliary data | ||
phpunit.xml.dist | Data | Auxiliary data | ||
prim.sublime-project | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (144) | / | .assets |
File | Role | Description |
---|---|---|
buy-me-a-coffee.svg | Data | Auxiliary data |
prim-logo.png | Icon | Icon image |
Files (144) | / | .changelog |
File | Role | Description |
---|---|---|
CURRENT.md | Data | Auxiliary data |
ROADMAP.md | Data | Auxiliary data |
UNRELEASED.md | Data | Auxiliary data |
Files (144) | / | .github |
File | Role | Description |
---|---|---|
CODE_OF_CONDUCT.md | Data | Auxiliary data |
CONTRIBUTING.md | Data | Auxiliary data |
ISSUE_TEMPLATE.md | Data | Auxiliary data |
PULL_REQUEST_TEMPLATE.md | Data | Auxiliary data |
Files (144) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Collections (1 file) | ||||
Contracts (2 files) | ||||
Exceptions (4 files, 1 directory) | ||||
Facades (1 file, 1 directory) | ||||
Scalars (4 files, 1 directory) | ||||
Support (1 file) | ||||
Traits (2 files) | ||||
ImmutableValueObject.php | Class | Class source | ||
register_extensions.php | Class | Class source | ||
scalar_functions.php | Example | Example script | ||
ValueObject.php | Class | Class source |
Files (144) | / | src | / | Contracts |
File | Role | Description |
---|---|---|
DotArrayAccess.php | Class | Class source |
ValueObject.php | Class | Class source |
Files (144) | / | src | / | Exceptions |
File | Role | Description | ||
---|---|---|---|---|
Scalars (1 directory) | ||||
ImmutableValueException.php | Class | Class source | ||
InvalidFacadeClassException.php | Class | Class source | ||
InvalidValueException.php | Class | Class source | ||
PropertyNotFoundException.php | Class | Class source |
Files (144) | / | src | / | Exceptions | / | Scalars | / | String |
File | Role | Description |
---|---|---|
RegexMatchException.php | Class | Class source |
Files (144) | / | src | / | Facades |
File | Role | Description | ||
---|---|---|---|---|
Scalars (4 files) | ||||
ValueObjectFacade.php | Class | Class source |
Files (144) | / | src | / | Facades | / | Scalars |
File | Role | Description |
---|---|---|
BoolFacade.php | Class | Class source |
FloatFacade.php | Class | Class source |
IntFacade.php | Class | Class source |
StringFacade.php | Class | Class source |
Files (144) | / | src | / | Scalars |
File | Role | Description | ||
---|---|---|---|---|
Extensions (4 directories) | ||||
BoolObject.php | Class | Class source | ||
FloatObject.php | Class | Class source | ||
IntObject.php | Class | Class source | ||
StringObject.php | Class | Class source |
Files (144) | / | src | / | Scalars | / | Extensions |
Files (144) | / | src | / | Scalars | / | Extensions | / | Bool |
File | Role | Description |
---|---|---|
BoolAndExtension.php | Class | Class source |
BoolEqualsExtension.php | Class | Class source |
BoolNotExtension.php | Class | Class source |
BoolOrExtension.php | Class | Class source |
BoolXorExtension.php | Class | Class source |
Files (144) | / | src | / | Scalars | / | Extensions | / | Float |
File | Role | Description |
---|---|---|
FloatCompareExtension.php | Class | Class source |
FloatEqualsExtension.php | Class | Class source |
Files (144) | / | src | / | Scalars | / | Extensions | / | Int |
File | Role | Description |
---|---|---|
IntAbsExtension.php | Class | Class source |
IntCompareExtension.php | Class | Class source |
IntEqualsExtension.php | Class | Class source |
Files (144) | / | src | / | Scalars | / | Extensions | / | String |
Files (144) | / | src | / | Traits |
File | Role | Description |
---|---|---|
HasPropertyAccessors.php | Class | Class source |
HasPropertyMutators.php | Class | Class source |
Files (144) | / | tests |
File | Role | Description | ||
---|---|---|---|---|
Feature (1 file) | ||||
Helpers (3 files, 1 directory) | ||||
Unit (2 files, 3 directories) | ||||
TestCase.php | Class | Class source |
Files (144) | / | tests | / | Helpers |
File | Role | Description | ||
---|---|---|---|---|
Facades (3 files) | ||||
DummyNonValueObject.php | Class | Class source | ||
DummyValueObject.php | Class | Class source | ||
ImmutableDummy.php | Class | Class source |
Files (144) | / | tests | / | Helpers | / | Facades |
File | Role | Description |
---|---|---|
DummyCompleteFacade.php | Class | Class source |
DummyInvalidFacade.php | Class | Class source |
DummyNonValueObjectFacade.php | Class | Class source |
Files (144) | / | tests | / | Unit |
File | Role | Description | ||
---|---|---|---|---|
Collections (1 file) | ||||
Facade (1 file) | ||||
Scalars (4 files, 4 directories) | ||||
ImmutableObjectTest.php | Class | Class source | ||
ValueObjectTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Facade |
File | Role | Description |
---|---|---|
ValueObjectFacadeTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Scalars |
File | Role | Description | ||
---|---|---|---|---|
Bool (4 files) | ||||
Float (2 files) | ||||
Int (3 files) | ||||
String (33 files) | ||||
BoolObjectTest.php | Class | Class source | ||
FloatObjectTest.php | Class | Class source | ||
IntObjectTest.php | Class | Class source | ||
StringObjectTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Scalars | / | Bool |
File | Role | Description |
---|---|---|
BoolAndTest.php | Class | Class source |
BoolNotTest.php | Class | Class source |
BoolOrTest.php | Class | Class source |
BoolXorTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Scalars | / | Float |
File | Role | Description |
---|---|---|
FloatCompareTest.php | Class | Class source |
FloatEqualsTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Scalars | / | Int |
File | Role | Description |
---|---|---|
IntAbsTest.php | Class | Class source |
IntCompareTest.php | Class | Class source |
IntEqualsTest.php | Class | Class source |
Files (144) | / | tests | / | Unit | / | Scalars | / | String |
File | Role | Description |
---|---|---|
StringAfterTest.php | Class | Class source |
StringAsciiTest.php | Class | Class source |
StringBeforeTest.php | Class | Class source |
StringCamelTest.php | Class | Class source |
StringCompareTest.php | Class | Class source |
StringContainsTest.php | Class | Class source |
StringEndsWithTest.php | Class | Class source |
StringEqualsTest.php | Class | Class source |
StringFinishTest.php | Class | Class source |
StringIsTest.php | Class | Class source |
StringKebabTest.php | Class | Class source |
StringLcfirstTest.php | Class | Class source |
StringLengthTest.php | Class | Class source |
StringLimitTest.php | Class | Class source |
StringLowerTest.php | Class | Class source |
StringRandomTest.php | Class | Class source |
StringRegexMatchesTest.php | Class | Class source |
StringRegexQuoteTest.php | Class | Class source |
StringReplaceArrayTest.php | Class | Class source |
StringReplaceFirstTest.php | Class | Class source |
StringReplaceLastTest.php | Class | Class source |
StringReplaceTest.php | Class | Class source |
StringSlugTest.php | Class | Class source |
StringSnakeTest.php | Class | Class source |
StringStartsWithTest.php | Class | Class source |
StringStartTest.php | Class | Class source |
StringStudlyTest.php | Class | Class source |
StringSubstrTest.php | Class | Class source |
StringTitleTest.php | Class | Class source |
StringUcfirstTest.php | Class | Class source |
StringUpperTest.php | Class | Class source |
StringUuidTest.php | Class | Class source |
StringWordsTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.