예제 #1
0
파일: SimpleMapTest.php 프로젝트: fwk/xml
 public function testFilteredValue()
 {
     $map = new Map();
     $map->add(Path::factory('/test/description', 'desc')->setDefault('value')->filter(function ($val) {
         return strrev($val);
     }));
     $result = $map->execute($this->object);
     $this->assertTrue(is_array($result));
     $this->assertArrayHasKey('desc', $result);
     $this->assertEquals(strrev("test description"), $result['desc']);
 }
예제 #2
0
파일: All.php 프로젝트: jgswift/qinq
 /**
  * Checks if all array values match given arguments
  * @return boolean
  */
 public function execute()
 {
     $arr = parent::execute();
     $args = $this->getArguments();
     foreach ($args as $arg) {
         if (!in_array($arg, $arr)) {
             return false;
         }
     }
     return true;
 }
예제 #3
0
파일: MapTest.php 프로젝트: fwk/xml
 public function testWrongPath()
 {
     $map = new Map();
     $map->add(Path::factory('/test', 'test')->addChildren(Path::factory('wrong>path', 'wrong', 'defaultFalse')));
     $result = $map->execute(new XmlFile(__DIR__ . '/test.xml'));
     $this->assertTrue(is_array($result));
     $this->assertArrayHasKey('test', $result);
     $this->assertTrue(is_array($result['test']));
     $this->assertArrayHasKey('wrong', $result['test']);
     $this->assertEquals('defaultFalse', $result['test']['wrong']);
 }
예제 #4
0
파일: Any.php 프로젝트: jgswift/qinq
 /**
  * Checks if any array value matches given arguments
  * @return boolean
  */
 public function execute()
 {
     $arr = parent::execute();
     $args = $this->getArguments();
     foreach ($args as $arg) {
         foreach ($arr as $value) {
             if ($value == $arg) {
                 return true;
             }
         }
     }
     return false;
 }
예제 #5
0
파일: Sum.php 프로젝트: jgswift/qinq
 /**
  * Adds all array values together
  * @return integer
  */
 public function execute()
 {
     return array_sum(parent::execute());
 }
예제 #6
0
파일: Max.php 프로젝트: jgswift/qinq
 /**
  * Retrieves item of largest value
  * @return integer
  */
 public function execute()
 {
     return max(parent::execute());
 }
예제 #7
0
파일: Average.php 프로젝트: jgswift/qinq
 /**
  * Retrieves the sum value of all array values
  * @return integer
  */
 public function execute()
 {
     $arr = parent::execute();
     return array_sum($arr) / count($arr);
 }