Test is getting failed when printing heart with intials
class HighSchoolSweetheart
{
public function firstLetter(string $name): string
{
return substr(trim($name), 0, 1);
throw new \BadFunctionCallException("Implement the function");
}
public function initial(string $name): string
{
$name = $this->firstLetter($name);
return ucfirst(trim($name)).".";
throw new \BadFunctionCallException("Implement the function");
}
public function initials(string $name): string
{
$name = explode(" ", $name);
return $this->initial($name[0]). " " . $this->initial($name[1]);
throw new \BadFunctionCallException("Implement the function");
}
public function pair(string $sweetheart_a, string $sweetheart_b): string
{
$sweetheart_a = $this->initials($sweetheart_a);
$sweetheart_b = $this->initials($sweetheart_b);
$line = $sweetheart_a . " + " . $sweetheart_b;
return <<<END
****** ******
** ** ** **
** ** ** **
** * **
** **
** {$line} **
** **
** **
** **
** **
** **
** **
***
*
END;
return $pattern;
throw new \BadFunctionCallException("Implement the function");
}
}
$sweetheart = new HighSchoolSweetheart();
$expected = <<<EXPECTED_HEART
****** ******
** ** ** **
** ** ** **
** * **
** **
** A. B. + C. D. **
** **
** **
** **
** **
** **
** **
***
*
EXPECTED_HEART;
$this->assertEquals(
$expected,
$sweetheart->pair('Avery Bryant', 'Charlie Dixon')
);