for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bavix\SDK;
use Bavix\Foundation\SharedInstance;
use Bavix\Helpers\Arr;
use Bavix\Helpers\Str;
class PathBuilder
{
use SharedInstance;
/**
* @var int
*/
protected $depth = 2;
protected $length = 2;
* @var string
protected $charPad = '0';
protected $typePad = STR_PAD_RIGHT;
* PathBuilder constructor.
*
* @param int $length
* @param int $depth
public function __construct($length = 2, $depth = 2)
$this->length = $length;
$this->depth = $depth;
}
* @param string $data
* @return string
protected function string($data)
return \str_pad(
$data,
$this->depth * $this->length,
$this->charPad,
$this->typePad
);
* @param int $data
public function setLength($data)
$this->length = $data;
public function setDepth($data)
$this->depth = $data;
public function setCharPad($data)
$this->charPad = $data;
public function setTypePad($data)
$this->typePad = $data;
* @param string $string
* @return array
public function hash($string)
return implode('/', Arr::slice(
Str::split($this->string($string), $this->length),
0, $this->depth
));
* <type>(/<config>)/<hash>{s1}/<hash>{s2}/<hash>
* @param string $type
* @param string $hash
* @param string $config
public function generate($type, $config, $hash)
return $type . '/' . $config . '/' . $this->hash($hash) . '/' . $hash;
$this->hash($hash)
array
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
return $type . '/' . $config . '/' . /** @scrutinizer ignore-type */ $this->hash($hash) . '/' . $hash;