for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Laravel Auditing package.
*
* @author Antério Vieira <[email protected]>
* @author Quetzy Garcia <[email protected]>
* @author Raphael França <[email protected]>
* @copyright 2015-2018
* For the full copyright and license information,
* please view the LICENSE.md file that was distributed
* with this source code.
*/
namespace OwenIt\Auditing\Redactors;
class RightRedactor implements \OwenIt\Auditing\Contracts\AuditRedactor
{
* {@inheritdoc}
public static function redact($value): string
$total = strlen($value);
$tenth = ceil($total / 10);
// Make sure single character strings get redacted
$length = ($total > $tenth) ? ($total - $tenth) : 1;
return str_pad(substr($value, 0, -$length), $total, '#', STR_PAD_RIGHT);
-$length
double
integer
$length
substr()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
return str_pad(substr($value, 0, /** @scrutinizer ignore-type */ -$length), $total, '#', STR_PAD_RIGHT);
}