public function getValue(FormatContext $context)
 {
     if ('' === $context->getPreviousValue()) {
         return '';
     }
     return $this->descriptor->getValue($context);
 }
 /**
  * @test
  * @dataProvider provideFormatContexts
  */
 public function it_provides_correct_format_context($format, $fields, FormatContext $context, $index)
 {
     /** @var FormatContext[] $contexts */
     $contexts = array();
     $descriptors = array();
     foreach ($fields as $field => $value) {
         $mock = $this->getMock('Jsor\\StringFormatter\\FieldDescriptor\\FieldDescriptorInterface');
         $mock->expects($this->any())->method('getCharacter')->will($this->returnValue($field));
         $mock->expects($this->once())->method('getValue')->will($this->returnValue($value));
         $mock->expects($this->once())->method('getReplacement')->will($this->returnCallback(function ($value, $context) use(&$contexts) {
             $contexts[] = $context;
             return $value;
         }));
         $descriptors[] = $mock;
     }
     $formatter = new StringFormatter($format, $descriptors, true);
     $formatter->format($fields);
     foreach ($fields as $field => $value) {
         $this->assertSame($context->hasValue($field), $contexts[$index]->hasValue($field));
         $this->assertSame($context->getValue($field), $contexts[$index]->getValue($field));
     }
     $this->assertSame($context->isStrict(), $contexts[$index]->isStrict());
     $this->assertSame($context->getPreviousValue(), $contexts[$index]->getPreviousValue());
     $this->assertSame($context->getPreviousCharacter(), $contexts[$index]->getPreviousCharacter());
     $this->assertSame($context->getPreviousFormatCharacter(), $contexts[$index]->getPreviousFormatCharacter());
 }