PHPackages                             nekland/tools - 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. nekland/tools

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

nekland/tools
=============

Just some tools to work better with PHP

2.6.2(3y ago)7387.9k↑11.5%35MITPHPPHP ^7.0 || ^8.0

Since Nov 3Pushed 3y ago4 watchersCompare

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

READMEChangelog (10)Dependencies (3)Versions (13)Used By (5)

Nekland Tools
=============

[](#nekland-tools)

[![Build Status](https://camo.githubusercontent.com/d3ea248aa4751e37f440860499575d1a044432e69b1e4d70e2997afddbb20985/68747470733a2f2f7472617669732d63692e6f72672f4e656b6c616e642f546f6f6c732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Nekland/Tools)

Just some classes helping to code with PHP in general. No dependencies. High quality code.

**This repository follows semver.**

Installation
------------

[](#installation)

```
composer require "nekland/tools"
```

Reference
---------

[](#reference)

This library provide some tools to help you with your developments.

Here is the list of tools it provides:

- [StringTools](#stringtools-class)
- [ArrayTools](#arraytools-class)
- [EqualableInterface](#equalableinterface)
- [DateTimeComparator](#datetimecomparator-class)
- [TemporaryFile](#temporary-file-management)
- [TemporaryDirectory](#temporary-directory-management)

### StringTools class

[](#stringtools-class)

**Encoding arguments are optionals.**

#### ::camelize

[](#camelize)

```
StringTools::camelize($str, $from, $encoding, $normalize = true) : string
```

- `$str` string input
- `$from` (optional, default "\_") input string format (can be "-" or "\_")
- `$encoding` (optional, default "UTF-8") encoding of your input string
- `$normalize` decide either you want to normalize (remove special characters) or not, that's what you want in most cases when camelizing

#### ::startsWith

[](#startswith)

Say if the given string starts with needle or not.

```
StringTools::startsWith($str, $start) : bool
```

- `$str` string input
- `$start` string it should starts with

#### ::endsWith

[](#endswith)

Say if the given string ends with needle or not.

```
StringTools::endsWith($str, $end) : bool
```

- `$str` string input
- `$end` string it should ends with

#### ::removeStart

[](#removestart)

Removes the start of the string if it matches with the given one.

```
StringTools::removeStart($str, $toRemove) : string
```

- `$str` string input
- `$toRemove` string to remove at the start of `$str`

#### ::removeEnd

[](#removeend)

Removes the end of the string if it matches with the given text to remove.

```
StringTools::removeEnd($str, $toRemove) : string
```

- `$str` string input
- `$toRemove` string to remove at the end of `$str`

#### ::contains

[](#contains)

```
StringTools::contains($str, $needle) : bool
```

- `$str` string input
- `$needle` potentially contained string

#### ::mb\_ucfirst

[](#mb_ucfirst)

Adds missing multi-byte PHP function for `ucfirst` standard function.

```
StringTools::mb_ucfirst($str, $encoding) : string
```

- `$str` string input
- `$encoding` (optional, default "UTF-8") encoding of your input string

### ArrayTools class

[](#arraytools-class)

#### ::removeValue

[](#removevalue)

```
ArrayTools::removeValue($array, $value) : void
```

- `$array` input array passed by reference
- `$value` The value to remove from the $array

### EqualableInterface

[](#equalableinterface)

Helps you equals on objects on a similar way as [java](http://stackoverflow.com/questions/1643067/whats-the-difference-between-equals-and).

#### equals

[](#equals)

Method that you must implements to check if the object taking as parameter is equals or not.

### DateTimeComparator class

[](#datetimecomparator-class)

For following methods `lowest` and `greatest`, you can provide unlimited `DateTimeInterface` objects. Please note that non DateTimeInterface objects will be ignored by functions.

#### ::greatest

[](#greatest)

Compare \\DateTimeInterface from parameters and return the greatest

```
DateTimeComparator::greatest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface
```

#### ::lowest

[](#lowest)

Compare \\DateTimeInterface from parameters and return the lowest

```
DateTimeComparator::lowest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface
```

### Temporary file management

[](#temporary-file-management)

The class `TemporaryFile` helps you to create temporary file with ease.

#### ::\_\_construct()

[](#__construct)

```
TemporaryFile::__construct(TemporaryDirectory $dir = null, string $prefix = '')
```

**Examples:**

```
// Create a file in temporary folder
$file = new TemporaryFile();

// Create a file inside a temporary directory (see TemporaryDirectory class)
$file = new TemporaryFile($temporaryDir);

// Create a file in a temporary folder with php_ prefix.
$file = new TemporaryFile(null, 'php_');
```

#### ::setContent &amp; ::getContent

[](#setcontent--getcontent)

```
TemporaryFile::setContent(string $content)
TemporaryFile::getContent(): string
```

#### ::getPathname()

[](#getpathname)

Returns the complete path to the file (ie: `/tmp/generated-folder/filename`)

```
TemporaryFile::getPathname(): string
```

#### ::remove()

[](#remove)

Removes the file from filesystem.

```
TemporaryFile::remove()
```

### Temporary directory management

[](#temporary-directory-management)

#### ::\_\_construct()

[](#__construct-1)

```
TemporaryDirectory::__construct(string $dir = null, string $prefix = 'phpgenerated')
```

**Examples:**

```
// create a new directory
$directory = new TemporaryDirectory();
```

#### ::getTemporaryFile()

[](#gettemporaryfile)

Create a `TemporaryFile` from the directory generated.

```
TemporaryDirectory::getTemporaryFile(): TemporaryFile
```

#### ::remove()

[](#remove-1)

Removes the directory.

```
TemporaryDirectory::remove(bool $force = false): void
```

*If `force` is specified to true, it will remove the directory even if it has files inside.*

#### ::getPathname()

[](#getpathname-1)

Returns the complete path to the folder (ie: `/tmp/folder-name`)

```
TemporaryDirectory::getPathname(): string
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 90.3% 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

Every ~231 days

Recently: every ~369 days

Total

11

Last Release

1169d ago

Major Versions

1.0.0 → 2.0.02017-08-01

PHP version history (2 changes)2.2.0PHP ^5.6 || ^7.0

2.6.0PHP ^7.0 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/132011?v=4)[Nikita (Anatolievich) Dudnik](/maintainers/Nek)[@Nek](https://github.com/Nek)

---

Top Contributors

[![Nek-](https://avatars.githubusercontent.com/u/972456?v=4)](https://github.com/Nek- "Nek- (65 commits)")[![Awkan](https://avatars.githubusercontent.com/u/15607661?v=4)](https://github.com/Awkan "Awkan (7 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nekland-tools/health.svg)

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

###  Alternatives

[yohang/oossh

Object Oriented SSH for PHP

363.8k](/packages/yohang-oossh)

PHPackages © 2026

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