for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Thinktomorrow\Chief\App\Console;
use Illuminate\Console\Command;
use Thinktomorrow\Chief\Admin\Users\User;
abstract class BaseCommand extends Command
{
protected function createUser(string $firstname, string $lastname, string $email, string $password, $roles = []): void
$user = new User();
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->email = $email;
$user->password = bcrypt($password);
$user->enabled = true;
$user->save();
$user->assignRole((array)$roles);
}
/**
* @return null|string
* @throws \Exception
*/
protected function askPassword()
$password = $passwordConfirm = null;
$tries = 0;
while (! $password || strlen($password) < 4 || $password != $passwordConfirm) {
$password
void
string
$string
strlen()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
while (! $password || strlen(/** @scrutinizer ignore-type */ $password) < 4 || $password != $passwordConfirm) {
if ($tries > 2) {
throw new \Exception('Aborting. Too many failed attempts to set password');
$password = $this->secret('Password (min. 5 chars)');
$passwordConfirm = $this->secret('Password (confirm)');
$tries++;
return $password;