Skip to content

A PHP library to chain methods like $mold->upperacase()->last(3)

Notifications You must be signed in to change notification settings

jenstornell/mold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mold

Version 2.0 Changelog

A PHP library to chain methods like $mold->upperacase()->last(3).

In short

  • Tiny library (below 1 kB)
  • Easy to write own plugins
  • No dependencies
  • Support for arguments

Usage

Here is an example of how it will look like.

// Include MoldBase class
include __DIR__ . '/mold.php';

// Include plugins
include __DIR__ . '/plugins/hello.php';

// Create a new instance
$mold = new Mold();

// Output the result on the screen, in this case "LD!"
echo $mold->set('Hello World!')->upperacase()->last(3);

Write a plugin

To create the plugin that is used in the example above, you can do it like below.

<?php
namespace Mold;

function trim($obj) {
  return \trim($obj->collection, $obj->args[0]);
}
  • You need the namespace Mold.
  • You need to include it as an internal file.

With the plugin above you can do something like below, which will output Hello World.

include __DIR__ . '/mold.php';
include __DIR__ . '/plugins/my-plugin.php';

$mold = new Mold();

echo $mold->set('Hello World!')->trim('!');

Requirements

  • PHP 7+

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

Donate

If you want to make a donation, you can do that by sending any amount https://www.paypal.me/DevoneraAB

About

A PHP library to chain methods like $mold->upperacase()->last(3)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages