Skip to content

Instantly share code, notes, and snippets.

@peterlafferty
Last active October 20, 2016 22:29
Show Gist options
  • Save peterlafferty/39340246bad32f74a6acd55dea3de0ee to your computer and use it in GitHub Desktop.
Save peterlafferty/39340246bad32f74a6acd55dea3de0ee to your computer and use it in GitHub Desktop.
<?php
function test($number, $text)
{
if (!is_int($number) || is_null($number)) {
throw new Exception('invalid argument type $number');
}
if (!is_string($text) || is_null($text)) {
throw new Exception('invalid argumenti type $string');
}
$number = test2($number);
return str_repeat($text, $number);
}
function test2($number)
{
if (!is_int($number) || is_null($number)) {
throw new Exception('invalid argument type $number');
}
return $number * 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment