PHPackages                             ascetik/primalvalues - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ascetik/primalvalues

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ascetik/primalvalues
====================

Simple classe to handle primitive types

v0.1.0(2y ago)0111MITPHP

Since Jan 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ascetik/primalvalues)[ Packagist](https://packagist.org/packages/ascetik/primalvalues)[ RSS](/packages/ascetik-primalvalues/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

primalvalues
============

[](#primalvalues)

Some Classes to handle primitive types

Release Notes
-------------

[](#release-notes)

> v.O.1.0 : draft

- **PrimalValue** interface - still incomplete
- **PrimalString** implementation - now a string can have its methods...
- **Numerik** implementation - a numeric value with methods.

PrimalString
------------

[](#primalstring)

An object oriented way to handle strings.

**PrimalString**'s constructor is private. To instanciate a PrimalString, use either of() or empty() static methods.

Methods and descriptions :

- **charAt**(*int* $index): *self*Returns a new self instance with the letter of the current value at given index. On negative $index, search starts from the end of current value. Empty instance if $index is higher than value's length.
- **concat**(*string|self* $sequence): *self*Returns a new self with the specified string appended to current string
- **contains**(*string/self* $sequence): *bool*Checks if current value contains given sequence.
- **endsWith**(*string/self* $sequence): *bool*Checks if current value ends with given sequence.
- **equals**(*mixed* $string): bool Checks value equality for a given **PrimalString**, strict equality otherwise.
- **indexOf**(*string/self* $sequence): int Returns the index of a sequence of this value, -1 if the sequence is not found
- **isEmpty**(): bool Checks if current value is empty
- **lastIndexOf**(string/self $sequence): *int*Returns the index of the last found sequence, -1 if not found
- **length**(): *int*Returns current value's length
- **matches**(string $regex): *bool*Checks current value format using a regular expression
- **replace**(*string|self|array* $oldVal, *string|self|array* $newVal): *self*Returns a new self instance with replaced sequence.
- **replaceAll**(*string|array* $regex, *string|self|array* $replacement): *self*Replaces from current value all sequences matching given expressions with replacements.
- **split**(*string* $regex): *array*Returns an array of string sequences from splitting current value using given regex pattern.
- **startsWith**(*string/self* $sequence): *bool*Checks if current value starts with given sequence.
- **subString**(*int* $offset, *?int* $length): *self*Returns a new self instance from current value starting from $offset with $length characters if given, until the end if not, or an empty self instance if an error occured.
- **toArray**(): *array*Returns an array of self instances for each character of current value.
- **toLowerCase**(): *self*Returns a new self instance with lower-cased current value.
- **toUpperCase**(): *self*Returns a new self instance with upper-cased current value.
- **trim**(*string|self|null* $chars): *self*Returns a new self instance from current value after removing trailing spaces and $chars at start and end.
- static **of**(*string* $sequence): *self*Returns a new self instance with given sequence
- static **empty**(): *self*Returns a new self empty instance

Numerik
-------

[](#numerik)

Object orientd way to handle numeric values. No difference is made between an integer and a float value in this version.

Private constructor. Use *of* or *zero* static methods to build a **Numerik** instance.

Methods and descriptions :

- **add**(*int|float|self* $number): *self*Return a new self instance with the sum of current value and the given one
- **cube**(): *self*Returns anw self instance with current value at power of 3.
- **decrement**(*int|float|self* $decrease = 1): self Returns a new self instance with current value decreased with given value.
- **divides**(*int|float|self* $dividend): *self*Returns a new self instance with the result of given number divided by self value. A zero self instance if returned if current value == 0
- **dividedBy**(*int|float|self* $divider): *self*Returns a new self instance with the result of self value divided by given number. A zero self instance if returned if $number == 0
- **equals**(): *bool*Checks strict equality between current instance and given value.
- **exposing**(*int|float|self* $number): *self*Returns self instance of given number raised to the power of current value.
- **increment**(*int|float|self* $increase = 1): self Returns a new self instance with current value increased with given value.
- **multiply**(*int|float|self* $number): self Returns a new self instance with the product of current value and given number.
- **power**(*int|float|self* $exponent): *self*Returns a self instance with current value raised at power $exponent.
- **square**(): *self*Returns anw self instance with current value at power of 2.
- **squareRoot**(): *self*Returns a self instance with current value square root.
- **subtract**(*int|float|self* $number): *self*Returns a self instance with current value minus $number.
- **subtractTo**(*int|float|self* $number): *self*Returns a self instance with $number minus current value.
- **toFloat**(): *float*Returns self instance with current value as integer.
- **toInteger**(): *int*Returns self instance with current value as integer.
- **value**(): *int|float*Returns current value
- static **of**(*int|float* $number): *self*Returns self instance with given number.
- static **zero**(): *self*Returns self instance with 0.

\## Next release

Maybe some more calculation methods for **Numerik** class, including trigonometric ones (cos, sin, tan...) Some other methods in **PrimalString** if i need to...

Are booleans concerned about this kind of consideration ? A boolean is either true or false, valid or not... What should i implement? A *valid()* method and that's all ? The *hypothetik* package already handles boolean case with the appropriate management.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

848d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a4d8042606038f6fe934a289278b31406405b77801d3e77142b29341a2614d6?d=identicon)[ascetik](/maintainers/ascetik)

---

Top Contributors

[![ascetik](https://avatars.githubusercontent.com/u/92370226?v=4)](https://github.com/ascetik "ascetik (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ascetik-primalvalues/health.svg)

```
[![Health](https://phpackages.com/badges/ascetik-primalvalues/health.svg)](https://phpackages.com/packages/ascetik-primalvalues)
```

###  Alternatives

[dueros/bot-sdk

度秘bot开发的PHP SDK

7514.4k1](/packages/dueros-bot-sdk)[devitek/yaml-configuration

Add YAML file support to Laravel Configuration

1614.1k](/packages/devitek-yaml-configuration)[gabrielanhaia/php-circuit-breaker

Circuit breaker pattern for PHP with multiple storage adapters, event system, and manual override.

151.2k1](/packages/gabrielanhaia-php-circuit-breaker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
