Syngr

by hassankhan

hassankhan / Syngr

Fixing the gaps in PHP's OO approach

127 Stars 3 Forks Last release: Not found 31 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Syngr Build Status Coverage Status

Syngr : SYNtactic suGaR

This project is an effort to consolidate PHP's wildly varying functions, and provide some sort of Standard Library for it.

Usage

The idea is to make programming in PHP simpler, and force it to behave in a more predictable manner. Most, if not all, methods for these types all operate on the object itself, which gives us a nice side-benefit of being able to chain multiple methods on an object.

String methods

$string = new String('hello world');
echo $string->uppercase()       // HELLO WORLD
            ->substring(0, 6)   // HELLO
            ->replace(' ', '?') // HELLO?
            ->trim('?');        // HELLO

Array conversion

join()
split()

Comparison

match()

Encoding

Hashing

hash($algorithm_name)
    where $algorithm_name can be anything from [here](http://www.php.net/manual/en/function.hash.php).

bcrypt($cost) where $cost is an integer between 4 and 31

HTML

Searching

String Formatting

Substring

substring($start, $length)
    where $start is the index to start the substring and $length is the length of the substring.

Text Formatting

trim()
uppercase()
lowercase()
pad()
length()
reverse()
replace()

Number methods

$number = new Number(6.9);
echo $number->ceiling()              // 7
            ->max(array(5, 9, 49.1)) // 49.1
            ->floor()                // 49
            ->sqrt()                 // Value
            ->value();               // Get raw value rather than string

Algebraic functions

absolute()
ceiling()
floor()
round()
max()
min()
sqrt()

Conversions

convert()

Random

random()

Transcendental functions

exp()
log()
pow()

Trigonometric

cos()
sin()
tan()

Project Setup

Clone the project somewhere,

cd
to the directory and type in
composer install
.

Syngr's dependencies are listed in the

composer.json
file, but if you're installing as a user then it has no extra dependencies (whoop!).

The best way to see Syngr in action is to look at the test code // Add an examples folder.

Testing

Unit Tests

Run

phpunit
from the terminal in the project folder to run unit tests.

Integration Tests

  1. Run other local services / provide credentials for external services.
  2. rake spec:integration

Documentation

From the project folder, type in

php vendor/bin/sami.php update gen-docs.php
. The documentation will be generated in a folder called 'docs'.

Troubleshooting & Useful Tools

Examples of common tasks

e.g.

  • How to make curl requests while authenticated via oauth.
  • How to monitor background jobs.
  • How to run the app through a proxy.

Contributing changes

  • Internal git workflow
  • Pull request guidelines
  • Tracker project
  • irc channel
  • Please open issues on the repo tracker for any incorrect behaviour, or better yet, make a pull request with a failing test case :smile:

License

This project is licensed under the MIT License.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.