```php
$padString = str_repeat($padCharacter, $padLength);

if ($padLeft) {
    return $padString . $value;
}

return $value . $padString;
```