Skip to content

Commit

Permalink
Merge 3fa2262 into f78fbf2
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeseekr committed Feb 2, 2015
2 parents f78fbf2 + 3fa2262 commit cc19745
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 53 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The following developers and/or companies helped contribute to building util.php
* PHP Experts, Inc. (http://www.phpexperts.pro/)
- `array_flatten()`
- `fix_broken_serialization()`
- Lots of unit tests.
* Tony Ferrara (ircmaxwell, http://blog.ircmaxell.com/)
- `seemsUtf8Regex()`: http://stackoverflow.com/a/11709412/430062
* Askar ([@ARACOOOL](https://github.com/ARACOOOL))
Expand All @@ -34,6 +35,8 @@ The following developers and/or companies helped contribute to building util.php
* Laravel Project (https://github.com/laravel/laravel)
- `secure_random_string()`: http://trac.allenjb.me.uk/php/browser/tagi/vendor/laravel/framework/src/Illuminate/Support/Str.php?rev=87#L127
* Abhimanyu Sharma ([@abhimanyusharma003](https://github.com/abhimanyusharma003))
- `limit_characters()`
- `limit_words()`
- `match_string()`
* Scott Baker ([@scottchiefbaker](https://github.com/scottchiefbaker))
* [@sergserg](https://github.com/sergserg)
Expand Down
27 changes: 20 additions & 7 deletions src/utilphp/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@ public static function is_serialized($data)
if ($data === 'N;') {
return true;
}
// Is it a serialized boolean?
elseif ($data === 'b:0;' || $data === 'b:1;') {
return true;
}

$length = strlen($data);

Expand All @@ -710,11 +714,6 @@ public static function is_serialized($data)
return false;
}

// Boolean values
if ($data === 'b:0;' || $data === 'b:1;') {
return true;
}

return @unserialize($data) !== false;
}

Expand Down Expand Up @@ -1355,6 +1354,8 @@ public static function number_to_word($number)
$groups2 = array();

foreach ($groups as $group) {
$group[1] = isset($group[1]) ? $group[1] : null;
$group[2] = isset($group[2]) ? $group[2] : null;
$groups2[] = self::numberToWordThreeDigits($group[0], $group[1], $group[2]);
}

Expand Down Expand Up @@ -1503,6 +1504,11 @@ protected static function numberToWordTwoDigits($digit1, $digit2)
}
}

/**
* @param $digit
* @return string
* @throws \LogicException
*/
protected static function numberToWordConvertDigit($digit)
{
switch ($digit) {
Expand All @@ -1526,6 +1532,8 @@ protected static function numberToWordConvertDigit($digit)
return 'eight';
case '9':
return 'nine';
default:
throw new \LogicException('Not a number');
}
}

Expand Down Expand Up @@ -1928,7 +1936,7 @@ public static function get_current_url()
// Get the rest of the URL
if (!isset($_SERVER['REQUEST_URI'])) {
// Microsoft IIS doesn't set REQUEST_URI by default
$url .= substr($_SERVER['PHP_SELF'], 1);
$url .= $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {
$url .= '?' . $_SERVER['QUERY_STRING'];
Expand Down Expand Up @@ -2044,14 +2052,19 @@ public static function ordinal($number)
}

/**
* Returns the file permissions as a nice string, like -rw-r--r--
* Returns the file permissions as a nice string, like -rw-r--r-- or false
* if the file is not found.
*
* @param string $file The name of the file to get permissions form
* @param int $perms Numerical value of permissions to display as text.
* @return string
*/
public static function full_permissions($file, $perms = null)
{
if (is_null($perms)) {
if (!file_exists($file)) {
return false;
}
$perms = fileperms($file);
}

Expand Down
37 changes: 10 additions & 27 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,19 @@ and can be run in your web browser.

PHP Unit >= 3.5.6

pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit
#### Installation of PHPUnit

vfsStream
# Download the PHPUnit phar.
wget https://phar.phpunit.de/phpunit.phar

pear channel-discover pear.bovigo.org
pear install bovigo/vfsStream-beta
# You can just run it locally. (Preferred for Windows)
php phpunit.phar --version


#### Installation of PEAR and PHPUnit on Ubuntu

Installation on Ubuntu requires a few steps. Depending on your setup you may
need to use 'sudo' to install these. Mileage may vary but these steps are a
good start.

# Install the PEAR package
sudo apt-get install php-pear

# Add a few sources to PEAR
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
pear channel-discover pear.bovigo.org

# Finally install PHPUnit and vfsStream (including dependencies)
pear install --alldeps phpunit/PHPUnit
pear install --alldeps bovigo/vfsStream-beta

# Finally, run 'phpunit' from within the ./tests directory
# and you should be on your way!
# Or install it system-wide.
mv phpunit.phar phpunit
chmod +x phpunit
sudo mv phpunit /usr/local/bin
phpunit --version

## Test Suites:

Expand Down
Loading

0 comments on commit cc19745

Please sign in to comment.