public function testMap()
 {
     $valid = ['id' => '3', 'priority' => 'low', 'status' => 'closed'];
     $invalid = ['subject' => 'special task'];
     $reflection = new \ReflectionClass('Diamante\\ApiBundle\\Tests\\Handler\\Fixtures\\Command');
     $mapper = new CommandProperties($reflection);
     $object = $mapper->map(array_merge($valid, $invalid));
     foreach ($valid as $key => $value) {
         $this->assertEquals($value, $object->{$key});
     }
     foreach ($invalid as $key => $value) {
         $this->assertObjectNotHasAttribute($key, $object);
     }
 }
 public function putIn(ParameterBag $bag)
 {
     $parameters = $this->method->getParameters();
     foreach ($parameters as $parameter) {
         if ($bag->has($parameter->getName())) {
             continue;
         }
         if ($parameter->getClass()) {
             $mapper = new CommandProperties($parameter->getClass());
             $command = $mapper->map($this->data);
             $command = $this->filterInput($command);
             $errors = $this->validator->validate($command);
             if (count($errors) > 0) {
                 $errorsString = (string) $errors;
                 throw new \InvalidArgumentException($errorsString);
             }
             $bag->set($parameter->getName(), $command);
         } elseif (array_key_exists($parameter->getName(), $this->data)) {
             $bag->set($parameter->getName(), $this->data[$parameter->getName()]);
         }
     }
 }