Skip to content

Commit

Permalink
Merge branch 'release-1.3.0' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffroy-aubry committed Jun 18, 2013
2 parents ae4b24f + 083bdd7 commit 3f3e9d9
Show file tree
Hide file tree
Showing 20 changed files with 1,522 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ChangeLog
=========

## Version 1.3.0 (2013-06-18)

Feature:

- Add `Debug` class with unit tests and doc.

## Version 1.2.2 (2013-06-14)

Doc:
Expand Down
92 changes: 79 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
[![Build Status](https://secure.travis-ci.org/geoffroy-aubry/Helpers.png?branch=stable)](http://travis-ci.org/geoffroy-aubry/Helpers)
[![Coverage Status](https://coveralls.io/repos/geoffroy-aubry/Helpers/badge.png?branch=stable)](https://coveralls.io/r/geoffroy-aubry/Helpers)

Some helpers used in several personal packages.
Some helpers used in several personal packages
and a `Debug` class useful for don't forgetting where debug traces are.

## Description

### Helpers class

Static methods of `Helpers` class:

* [arrayMergeRecursiveDistinct](#desc.arrayMergeRecursiveDistinct)
Expand All @@ -20,7 +24,7 @@ Static methods of `Helpers` class:
* [utf8Encode](#desc.utf8Encode)

<a name="desc.arrayMergeRecursiveDistinct"></a>
### arrayMergeRecursiveDistinct()
#### arrayMergeRecursiveDistinct()
```php
/**
* array_merge_recursive() does indeed merge arrays, but it converts values with duplicate
Expand Down Expand Up @@ -56,7 +60,7 @@ public static function arrayMergeRecursiveDistinct (array $aArray1, array $aArra
```

<a name="desc.exec"></a>
### exec()
#### exec()
```php
/**
* Executes the given shell command and returns an array filled with every line of output from the command.
Expand All @@ -74,7 +78,7 @@ public static function exec ($sCmd, $sOutputPath = '', $sErrorPath = '', $bAppen
```

<a name="desc.flattenArray"></a>
### flattenArray()
#### flattenArray()
```php
/**
* Flatten a multidimensional array (keys are ignored).
Expand Down Expand Up @@ -107,7 +111,7 @@ Array(
```

<a name="desc.intToMultiple"></a>
### intToMultiple()
#### intToMultiple()
```php
/**
* Returns specified value in the most appropriate unit, with that unit.
Expand Down Expand Up @@ -139,7 +143,7 @@ Array(
```

<a name="desc.numberFormat"></a>
### numberFormat()
#### numberFormat()
```php
/**
* Format a number with grouped thousands.
Expand All @@ -155,7 +159,7 @@ public static function numberFormat ($fNumber, $sDecPoint = '.', $sThousandsSep
```

<a name="desc.isAssociativeArray"></a>
### isAssociativeArray()
#### isAssociativeArray()
```php
/**
* Returns TRUE iff the specified array is associative.
Expand All @@ -170,7 +174,7 @@ public static function isAssociativeArray (array $aArray);
```

<a name="desc.round"></a>
### round()
#### round()
```php
/**
* Rounds specified value with precision $iPrecision as native round() function, but keep trailing zeros.
Expand All @@ -183,7 +187,7 @@ public static function round ($fValue, $iPrecision = 0);
```

<a name="desc.stripBashColors"></a>
### stripBashColors()
#### stripBashColors()
```php
/**
* Remove all Bash color sequences from the specified string.
Expand All @@ -195,7 +199,7 @@ public static function stripBashColors ($sMsg);
```

<a name="desc.strPutCSV"></a>
### strPutCSV()
#### strPutCSV()
```php
/**
* Formats a line passed as a fields array as CSV and return it, without the trailing newline.
Expand All @@ -210,7 +214,7 @@ public static function strPutCSV ($aInput, $sDelimiter = ',', $sEnclosure = '"')
```

<a name="desc.ucwordWithDelimiters"></a>
### ucwordWithDelimiters()
#### ucwordWithDelimiters()
```php
/**
* Returns a string with the first character of each word in specified string capitalized,
Expand All @@ -233,7 +237,7 @@ echo Helpers::ucwordWithDelimiters("hel-lo wo'rld", array('-', "'"));
```

<a name="desc.utf8Encode"></a>
### utf8Encode()
#### utf8Encode()
```php
/**
* Returns the UTF-8 translation of the specified string, only if not already in UTF-8.
Expand All @@ -244,6 +248,66 @@ echo Helpers::ucwordWithDelimiters("hel-lo wo'rld", array('-', "'"));
public static function utf8Encode ($str);
```

### Debug class

Debug class useful for don't forgetting where debug traces are.

Automatically decorates `print_r()` and `var_dump()` with following information:
* file and line of the caller
* name of function/method containing the call
* name of the parameter passed during call

#### Demo

See [debug.php](examples/debug.php) script for an example:
```bash
$ php examples/debug.php
```

Here is the result:

![result of debug.php](examples/debug.png "result of debug.php")

#### htmlVarDump()
```php
/**
* Display an HTML trace containing a var_dump() of the specified value.
*
* @param mixed $mValue value to pass to var_dump()
*/
public static function htmlVarDump ($mValue);
```

#### htmlPrintr()
```php
/**
* Display an HTML trace containing a print_r() of the specified value.
*
* @param mixed $mValue value to pass to print_r()
*/
public static function htmlPrintr ($mValue);
```

#### printr()
```php
/**
* Display a CLI trace containing a print_r() of the specified value.
*
* @param mixed $mValue value to pass to print_r()
*/
public static function printr ($mValue);
```

#### varDump()
```php
/**
* Display a CLI trace containing a var_dump() of the specified value.
*
* @param mixed $mValue value to pass to var_dump()
*/
public static function varDump ($mValue);
```

## Usage

**Helpers** is available via [Packagist](https://packagist.org/packages/geoffroy-aubry/helpers).
Expand All @@ -266,14 +330,16 @@ $ curl -sS https://getcomposer.org/installer | php
```
and run `php composer.phar install` from the terminal into the root folder of your project.

3. Include Composer's autoloader and use the `GAubry\Helpers` class:
3. Include Composer's autoloader and use the `GAubry\Helpers` classes:
```php
<?php

require_once 'vendor/autoload.php';
use GAubry\Helpers\Helpers;
use GAubry\Helpers\Debug;

Helpers::exec('ls -l /var/log');
Debug::printr($value);
```

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "geoffroy-aubry/helpers",
"description": "Some helpers used in several personal packages.",
"keywords": ["helpers", "tools"],
"description": "Some helpers used in several personal packages and a Debug class useful for don't forgetting where debug traces are.",
"keywords": ["helpers", "tools", "debug"],
"type": "library",
"license": "LGPL-3.0+",
"authors": [
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion doc/api/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Page not found | Helpers</title>

<script type="text/javascript" src="resources/combined.js?7177839"></script>
<script type="text/javascript" src="elementlist.js?3857017594"></script>
<script type="text/javascript" src="elementlist.js?2378676327"></script>
<link rel="stylesheet" type="text/css" media="all" href="resources/style.css?3505392360" />

</head>
Expand Down Expand Up @@ -36,6 +36,7 @@ <h3>Namespaces</h3>
<div id="elements">
<h3>Classes</h3>
<ul>
<li><a href="class-GAubry.Helpers.Debug.html">GAubry\Helpers\Debug</a></li>
<li><a href="class-GAubry.Helpers.Helpers.html">GAubry\Helpers\Helpers</a></li>
</ul>

Expand Down

0 comments on commit 3f3e9d9

Please sign in to comment.