PHP Berserker

PHP Berserker have only one objective, and is to group all functions in classes to make the programming process more comfortable.

Berserk will not give new functionalities for your program, but you could go directly to the function you want with it.

For example: you want a function of string. With Berserker, you could do bString:: and the IDE you use give you all the functions for strings that berserk have that are PHP functions for strings.

¿Why Berserker? Well, the name sound good to me.

¿And the project? – Golang and other language like Python you can easily get the function that are in the packages or modules respectively. Why in PHP not, why not use the power of your IDE to tell you what function could you use here.

¿Why this Project? – I want to give centralized access to the functions like in package, and the second reason is why not.

¿State of the Project? – Alpha 1.0.1 /open source

IMPORTANT: You will need at least PHP 8.1.0 to run berserker

Old version and Composer version

old-version

In order to use the old version, you need to download it at the GitHub

the berserker.php will load the following classes: bString.php, bArrays.php and bFilters for now.

Berserker use these flags BERSERKER_STATIC and BERSERKER_IMETHOD to determine if use static clasess or Instance Methods you can change these flag a t berserker.php

I added an index.php as an example

Composer version

Composer version is the default you can directly use it if you are making a project that use composer, please don’t use v1.0.0-Alpha that’s a version with problems instead use 1.0.1-Alpha

The state of alpha is cause that the project need to add some native functions to the berserker classes, as soon as I add that classes the project will be beta

how can I use it?

require 'vendor/autoload.php';
use Berserker\Berserker;
$berserker = new Berserker();// you can use new Berserker() too instead of assigning berserker to a varaible

On composer version, you can use instantiated methods too while you add a string parameter while you are invoking Berserker, could it what ever you want but i recommend you to use “IMETHOD” instead of using whatever you want.

new Berserker("x");

Berserker classes

bStrings

Let’s check what bStrings offers you for now:

  • subString -uses PHP substr
    • while use BERSERKER_STATIC
      bString::subString(string $text,string $offset,int $length= null):string
    • BERSERKER_IMETHOD
      $bString->subString(string $text,string $offset,int $length= null):string
      
  • trimBoth – uses PHP trim
    • bStrings::trimBoth(string $str, string $character_mask = " \t\n\r\0\x0B"): string
      

      $bString->trimBoth(string $str, string $character_mask = " \t\n\r\0\x0B"): string
      
  • trimLeft – uses PHP ltrim
  • trimRight – uses PHP rtrim
  • htmlEntities – uses PHP htmlentities
  • htmlSpecialChars – uses PHP htmlspecialchars
  • stripTags – uses PHP strip_tags
  • addSlashes – uses PHP addslashes
  • implode – uses PHP implode
  • explode – uses PHP explode
  • chopFromString – uses PHP strstr
  • findFirstPosition – uses PHP stripos
  • contains – uses PHP str_contains
  • length – uses PHP strlen
  • binToHex – uses PHP bin2Hex
  • cvsToArray – uses PHP str_getcsv
  • uppercase – uses PHP strtoupper
  • lowercase – uses PHP strtolower

bArrays

The following is the list of methods in bArrays for now:

bFilters