Example #1
0
function getSellByDate($productCode, $supplierId, $deliveryDate)
{
    switch (true) {
        case isApple($productCode):
            $time = '2 weeks';
            break;
        case isBanana($productCode):
            $time = '5 days';
            break;
        default:
            $time = '1 week';
            break;
    }
    $sellByDate = DateTime::createFromFormat('Y/m/d', $deliveryDate);
    $sellByDate->add(DateInterval::createFromDateString($time));
    if (in_array($supplierId, array(32, 101))) {
        $sellByDate->sub(DateInterval::createFromDateString('3 days'));
    }
    return $sellByDate->format('Y/m/d');
}
Example #2
0
        return true;
    } else {
        return false;
    }
}
function isRed($objectColor)
{
    if ($objectColor == "red") {
        return true;
    } else {
        return false;
    }
}
if (isValidInput()) {
    $objectName = $_GET["name"];
    if (isApple($objectName)) {
        if (isJuicy($objectHasJuice)) {
            if (isRed($objectColor)) {
                echo "Mmmmm... This is a red juicy apple!";
            } else {
                echo "Gross... This isn't a red juicy apple!";
            }
        } else {
            echo "Gross... This isn't a red juicy apple!";
        }
    } else {
        echo "Gross... This isn't a red juicy apple!";
    }
} else {
    echo "Invalid input!";
}
Example #3
0
    }
}
function isValidTerm($userItem)
{
    $validObject = ["apple", "hammer", "car", "banana"];
    foreach ($validObject as $item) {
        if ($item == $userItem) {
            return true;
        } else {
        }
    }
    return false;
}
if (isValidInput()) {
    $userItem = $_GET['name'];
    if (isApple($userItem)) {
        if (isJuicy($objectHasJuice)) {
            if (isRed($objectColor)) {
                echo "Let's buy this thing!";
            } else {
                echo "Do not buy, this is not a red, juicy, apple!";
            }
        } else {
            echo "Do not buy, this is not a red, juicy, apple!";
        }
    } else {
        echo "Do not buy, this is not a red, juicy, apple!";
    }
} else {
    echo "Invalid Input";
}