/**
  * Format a field value.
  *
  * @param string $field   Field name.
  * @param mixed  $value   Field value.
  * @param mixed  $context Context object, usually the data container driver.
  *
  * @return array|null|string
  */
 public function formatValue($field, $value, $context = null)
 {
     $fieldDefinition = $this->definition->get(['fields', $field]);
     // Not found.
     if (!is_array($fieldDefinition)) {
         return '';
     }
     if ($this->valueFormatter->accepts($field, $fieldDefinition)) {
         $value = $this->valueFormatter->format($value, $field, $fieldDefinition, $context);
     }
     return $value;
 }
 function it_applies_matching_formatters(ValueFormatter $formatterA, ValueFormatter $formatterB)
 {
     $formatterA->accepts(Argument::cetera())->willReturn(false);
     $formatterA->format(Argument::cetera())->shouldNotBeCalled();
     $formatterB->accepts(Argument::cetera())->willReturn(true);
     $formatterB->format(Argument::cetera())->shouldBeCalled()->willReturn('bar');
     $this->format('foo', 'test', [])->shouldReturn('bar');
 }
 function it_returns_initial_value_when_no_formatter_matches(ValueFormatter $formatterA, ValueFormatter $formatterB)
 {
     $formatterA->accepts(Argument::cetera())->willReturn(false);
     $formatterB->accepts(Argument::cetera())->willReturn(false);
     $this->format('foo', 'test', [])->shouldReturn('foo');
 }