private static function createFieldStrategy(FilterRule $rule)
 {
     if ($rule->isObjectRule()) {
         $strategy = new Strategy\ObjectToArrayStrategy($rule);
         if (count($rule->nestedFilters) > 0) {
             $strategy = new Strategy\ObjectSubsetStrategy($strategy);
         }
     } else {
         $strategy = new Strategy\AssocArrayEncodeStrategy($rule);
     }
     foreach ($rule->nestedFilters as $field => $r) {
         $strategy->append($field, static::createFieldStrategy($r));
     }
     return $strategy;
 }
 /**
  * @test
  */
 public function test_assoc_array_strategy()
 {
     $strategy = new Strategy\AssocArrayEncodeStrategy($this->newRule(['a']));
     $strategy->append('b', new Strategy\ObjectSubsetStrategy(new Strategy\ObjectToArrayStrategy($this->newRule(['a', 'b', 'd']))));
     $values = ['a' => 777, 'b' => new Target\PrivateClass('aa', 'bb', 999, 12345, 'xyz'), 'c' => 'ghjk'];
     $result = $strategy->serialize($values, []);
     $this->assertEquals(['a' => 777, 'b' => ['a' => 'aa', 'b' => 'bb', 'd' => 12345]], $result);
 }