Giter Club home page Giter Club logo

Phootwork library

Tests Coverage report Build Api Documentation Scrutinizer Code Quality Code Coverage Maintainability Test Coverage License

Phootwork is a collection of php libraries which fill gaps in the php language and provides consistent object oriented solutions where the language natively offers only functions.

The phootwork package includes:

  • collection a library to model several flavours of collections
  • file an object oriented library to manipulate filesystems elements (stream compatible)
  • json a json library, with clean syntax and proper error handling
  • lang a library to manipulate arrays and strings in an object oriented way
  • tokenizer an easy to use tokenizer library for PHP code
  • xml an object oriented xml utility library

Installation

We use composer as dependency manager and distribution system. To install the library run:

composer require phootwork/phootwork

Each single package can be installed separately. I.e. if you want to include in your project the collection library only:

composer require phootwork/collection

Note: the single library packages does not ship with tests and --dev dependencies. If you want to run the test suite or contribute to the library, you have to install the whole phootwork/phootwork package.

A Little Taste

The following examples show what you can find in this library. You can discover much, much more by reading the documentation and the api.

A Little Taste of lang Library (phootwork\lang\Text class);

<?php declare(strict_types=1);
/**
 * Example describing how to manipulate a string via the Text class
 * and its nice fluent api.
 */
use phootwork\lang\Text;

$text = new Text('a beautiful string');

// Remove the substring 'a ' and capitalize. Note: Text objects are *immutable*, 
// so you should assign the result to a variable
$text = $text->slice(2)->toCapitalCase(); // 'Beautiful string'

// Capitalize each word and add an 's' character at the end of the string
$text = $text->toCapitalCaseWords()->append('s'); // 'Beautiful Strings'

// Calculate the length of the string
$length = $text->length(); // 17

// Check if the string ends with the 'ngs' substring
$text->endsWith('ngs'); // true

A Little Taste of collection Library (phootwork\collection\Stack class)

<?php declare(strict_types=1);
/**
 * Example describing how to manipulate a Stack collection (Last In First Out)
 * via the Stack class
 */
use phootwork\collection\Stack;

$stack = new Stack(['Obiwan', 'Luke', 'Yoda', 'Leila']);

// Sort the stack
$stack = $stack->sort(); // ['Leila', 'Luke', 'Obiwan', 'Yoda']

// Check if the collection contains any elements
$stack->isEmpty();  // false

// How many elements?
$stack->size(); // 4

// Push an elememt
$stack->push('Chewbecca');

// How many elements now?
$stack->size(); // 5

// Peek the head element (return the head element, without removing it)
$stack->peek(); // 'Chewbecca'
$stack->size(); // 5

// Pop the head element
$stack->pop(); // 'Chewbecca'
$stack->size(); // 4: pop() removes the popped element

Documentation

The official documentation site: https://phootwork.github.io

Running Tests

In order to run the test suite, download the full library:

git clone https://github.com/phootwork/phootwork

Then install the dependencies via composer:

composer install

and run:

composer test

Our test script calls the vendor/bin/phpunit command under the hood, so you can pass to it all the phpunit options, via -- operator i.e.: composer test -- --stop-on-failure.

Each library has its own test suite and you can run it separately. I.e. suppose you want to run the collection library test suite:

composer test -- --testsuite collection

or alternatively:

vendor/bin/phpunit --testsuite collection

Phootwork also provides a command to generate a code coverage report in html format, into the coverage/ directory:

composer coverage

Contact

Report issues at the github Issue Tracker.

Contributing

Every contribute is welcome, whether it is a simple typo or a new modern complicated feature. We are very grateful to all the people who will dedicate their precious time to this library!

You can find all information about it in the CONTRIBUTING.md document.

Changelog

Refer to Releases

phootwork's Projects

api icon api

Phootwork api documentation

collection icon collection

[READ-ONLY] PHP Collections library (List, Set, Map, Queue & Stack)

file icon file

[READ-ONLY] File Operations for the local Filesystem

json icon json

[READ-ONLY] PHP json wrapper library

lang icon lang

[READ-ONLY] Missing PHP language constructs

phootwork icon phootwork

The phootwork php library fills gaps in the php language and provides better solutions than the existing ones php offers.

xml icon xml

[READ-ONLY] XML utilities

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.