Skip to content

Commit

Permalink
use version 0.5 of infuse/libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared King committed Dec 22, 2015
1 parent a07e687 commit ebdf08a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"pimple/pimple": ">=v2.1.0",
"symfony/event-dispatcher": "~2.7",
"jaqb/jaqb": "~1.1",
"infuse/libs": "dev-master"
"infuse/libs": "~0.5"
},
"require-dev": {
"satooshi/php-coveralls": "dev-master",
Expand Down
21 changes: 10 additions & 11 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace Pulsar;

use ICanBoogie\Inflector;
use Infuse\Utility;
use Pulsar\Driver\DriverInterface;
use Pulsar\Relation\HasOne;
use Pulsar\Relation\BelongsTo;
Expand Down Expand Up @@ -465,7 +464,7 @@ public static function getProperties()
*/
public static function getProperty($property)
{
return Utility::array_value(static::$properties, $property);
return array_value(static::$properties, $property);
}

/**
Expand Down Expand Up @@ -797,19 +796,19 @@ public function toArrayDeprecated(array $exclude = [], array $include = [], arra
// apply namespacing to $exclude
$namedExc = [];
foreach ($exclude as $e) {
Utility::array_set($namedExc, $e, true);
array_set($namedExc, $e, true);
}

// apply namespacing to $include
$namedInc = [];
foreach ($include as $e) {
Utility::array_set($namedInc, $e, true);
array_set($namedInc, $e, true);
}

// apply namespacing to $expand
$namedExp = [];
foreach ($expand as $e) {
Utility::array_set($namedExp, $e, true);
array_set($namedExp, $e, true);
}

// remove excluded properties
Expand Down Expand Up @@ -856,14 +855,14 @@ private function toArrayExpand(array $result, array $namedExc, array $namedInc,
continue;
}

$subExc = Utility::array_value($namedExc, $k);
$subInc = Utility::array_value($namedInc, $k);
$subExc = array_value($namedExc, $k);
$subInc = array_value($namedInc, $k);

// convert exclude, include, and expand into dot notation
// then take the keys for a flattened dot notation
$flatExc = is_array($subExc) ? array_keys(Utility::array_dot($subExc)) : [];
$flatInc = is_array($subInc) ? array_keys(Utility::array_dot($subInc)) : [];
$flatExp = is_array($subExp) ? array_keys(Utility::array_dot($subExp)) : [];
$flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : [];
$flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : [];
$flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : [];

$relation = $this->relation($k);
$result[$k] = $relation->toArrayDeprecated($flatExc, $flatInc, $flatExp);
Expand Down Expand Up @@ -1534,6 +1533,6 @@ private function checkUniqueness(array $property, $propertyName, $value)
*/
private function getPropertyDefault(array $property)
{
return Utility::array_value($property, 'default');
return array_value($property, 'default');
}
}
18 changes: 9 additions & 9 deletions src/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static function processRequirement(&$value, $requirement)
*/
private static function alpha(&$value, array $parameters)
{
return preg_match('/^[A-Za-z]*$/', $value) && strlen($value) >= Utility::array_value($parameters, 0);
return preg_match('/^[A-Za-z]*$/', $value) && strlen($value) >= array_value($parameters, 0);
}

/**
Expand All @@ -108,7 +108,7 @@ private static function alpha(&$value, array $parameters)
*/
private static function alpha_numeric(&$value, array $parameters)
{
return preg_match('/^[A-Za-z0-9]*$/', $value) && strlen($value) >= Utility::array_value($parameters, 0);
return preg_match('/^[A-Za-z0-9]*$/', $value) && strlen($value) >= array_value($parameters, 0);
}

/**
Expand All @@ -122,7 +122,7 @@ private static function alpha_numeric(&$value, array $parameters)
*/
private static function alpha_dash(&$value, array $parameters)
{
return preg_match('/^[A-Za-z0-9_-]*$/', $value) && strlen($value) >= Utility::array_value($parameters, 0);
return preg_match('/^[A-Za-z0-9_-]*$/', $value) && strlen($value) >= array_value($parameters, 0);
}

/**
Expand Down Expand Up @@ -164,7 +164,7 @@ private static function email(&$value, array $parameters)
*/
private static function enum(&$value, array $parameters)
{
$enum = explode(',', Utility::array_value($parameters, 0));
$enum = explode(',', array_value($parameters, 0));

return in_array($value, $enum);
}
Expand Down Expand Up @@ -232,7 +232,7 @@ private static function matching(&$value)
*/
private static function numeric(&$value, array $parameters)
{
$check = 'is_'.Utility::array_value($parameters, 0);
$check = 'is_'.array_value($parameters, 0);

return (!isset($parameters[0])) ? is_numeric($value) : $check($value);
}
Expand All @@ -254,7 +254,7 @@ private static function password(&$value, array $parameters)
return false;
}

$value = Utility::encrypt_password($value, self::$config['salt']);
$value = Utility::encryptPassword($value, self::$config['salt']);

return true;
}
Expand Down Expand Up @@ -311,8 +311,8 @@ private static function string(&$value, array $parameters)
}

$len = strlen($value);
$min = Utility::array_value($parameters, 0);
$max = Utility::array_value($parameters, 1);
$min = array_value($parameters, 0);
$max = array_value($parameters, 1);

return $len >= $min && (!$max || $len <= $max);
}
Expand All @@ -336,7 +336,7 @@ private static function time_zone(&$value)
}
unset($valid['']);

return !!Utility::array_value($valid, $value);
return !!array_value($valid, $value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/ValidateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license MIT
*/

use Infuse\Utility as U;
use Infuse\Utility;
use Pulsar\Validate;

class ValidateTest extends PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testPassword()

$password = 'testpassword';
$this->assertTrue(Validate::is($password, 'password:8'));
$this->assertEquals(U::encrypt_password('testpassword', $salt), $password);
$this->assertEquals(Utility::encryptPassword('testpassword', $salt), $password);

$invalid = '...';
$this->assertFalse(Validate::is($invalid, 'password:8'));
Expand Down

0 comments on commit ebdf08a

Please sign in to comment.