I have been working on this project for approximately a day now, and I am still struggling to solve the 7th part. Although I am not certain if I made any errors, my code is not providing the output I need.
Code:
<?php
class StringUtils {
public static function secondCase($string){
$string = strtolower($string);
$string[1] = strtoupper($string[1]);
if(strlen($string) >= 2){
$string[1] = strtoupper($string[1]);
};
return $string;
}
}
class Pajamas {
private $owner, $fit, $color;
function __constructor(
$owner = "Unclaimed",
$fit = "great",
$color = "silver"
){
$this->owner = StringUtils::secondCase($owner);
$this->fit = $fit;
$this->color = $color;
}
public function describe() {
return "{$this->owner} owns a {$this->color} PJ with a fit of {$this->fit}.";
}
}
$chicken_PJs = new Pajamas("CHICKEN", "regular", "green");
echo $chicken_PJs->describe();
//Expected Output: cHicken owns green PJs with a fit of regular.
Project: Going To Bed