예제 #1
0
파일: ArrayTest.php 프로젝트: jgswift/qtil
 function testCollectionClear()
 {
     $collection = new qtil\Collection();
     $collection->insert('foo', 'bar');
     $collection->clear();
     $count = count($collection);
     $this->assertEquals(0, $count);
 }
예제 #2
0
파일: Cache.php 프로젝트: jgswift/qio
 /**
  * executes all rules, enabling them
  * @param array $rules
  * @return Base
  */
 public function applyRules(array $rules = [])
 {
     if (!empty($rules)) {
         $this->rules->fromArray($rules);
     }
     if (count($rules) > 0) {
         foreach ($rules as $rule) {
             if (is_callable($rule)) {
                 $rule($this);
             }
         }
     }
     return $this;
 }
예제 #3
0
파일: Mapping.php 프로젝트: jgswift/kfiltr
 /**
  * Default mapping constructor
  * @param array $mapping
  * @param \Closure $namingCallback
  */
 function __construct()
 {
     $args = func_get_args();
     $data = [];
     if (func_num_args()) {
         foreach ($args as $a) {
             if (qtil\ArrayUtil::isIterable($a)) {
                 $data = $a;
             } elseif (is_callable($a)) {
                 $this->setNamingCallback($a);
             }
         }
     }
     parent::__construct($data);
 }
예제 #4
0
 /**
  * Helper method to create blank model if none found
  * @param string $className
  * @return persistr\Model\Blank
  */
 private static function createBlankPersistor($className)
 {
     $datasource = new qtil\Collection();
     $persistenceModel = new PersistenceModel($datasource);
     $persistor = new Persistor($className, $persistenceModel);
     self::register($persistor);
     $model = new Model\Blank($className);
     $datasource->insert($className, $model);
     return $persistor;
 }
예제 #5
0
 function testCollectionFromCollection()
 {
     $data = range(0, 3);
     $collection = new qtil\Collection();
     $collection->merge($data);
     $collection2 = new qtil\Collection();
     $collection2->fromCollection($collection);
     $this->assertEquals($collection->toArray(), $collection2->toArray());
 }