/** * Transforms an object (organization) to a string (code). * * @param OrganizationInterface|null $organization * * @return string */ public function transform($organization) { if (null === $organization) { return ''; } if (!$organization instanceof OrganizationInterface) { throw new UnexpectedTypeException($organization, OrganizationInterface::class); } return $organization->getCode(); }
public function it_should_transform_organization_into_its_code(OrganizationInterface $organization) { $organization->getCode()->willReturn('123abc'); $this->transform($organization)->shouldReturn('123abc'); }