Showing 26 of 33 total issues
UserService
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class UserService implements UserServiceContract
{
private UserRepositoryContract $userRepository;
/**
Method run
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run()
{
$admin = Role::findOrCreate(UserRole::ADMIN, 'api');
$tutor = Role::findOrCreate(UserRole::TUTOR, 'api');
$student = Role::findOrCreate(UserRole::STUDENT, 'api');
Method instantiateFromRequest
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function instantiateFromRequest(Request $request): self
{
$criteria = new Collection();
if ($request->get('search')) {
Function putUsingDto
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function putUsingDto(UserUpdateDto $dto, int $id): User
{
$data = $dto->toArray();
$user = $this->userRepository->update($data, $id);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function patchUsingDto
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function patchUsingDto(UserUpdateDto $dto, UserUpdateKeysDto $keysDto, int $id): User
{
$data = $dto->toArray();
$user = $this->userRepository->update($data, $id);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(bool $firstName = false, bool $lastName = false, bool $age = false, bool $gender = false, bool $country = false, bool $city = false, bool $street = false, bool $postcode = false, bool $email = false, bool $roles = false, bool $password = false)
Method searchNameWithBreadcrumbs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function searchNameWithBreadcrumbs(Builder $q, string $driver, string $like): Builder
{
$cast = 'name::varchar';
// check mysql version
if ($driver !== 'pgsql') {
Function instantiateFromRequest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function instantiateFromRequest(Request $request): self
{
$criteria = new Collection();
if ($request->get('search')) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method toArray
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($request)
{
$fields = array_filter([
'id' => $this->resource->getKey(),
'name' => $this->resource->name,
Method rules
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function rules()
{
$rules = [
'first_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
'last_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
Method getReturnUrl
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getReturnUrl(string $provider, ?string $returnUrl, ?string $state): string
{
$socialUser = Socialite::driver($provider)->stateless()->user();
$socialAccount = $this->socialAccountRepository->findByProviderAndProviderId($provider, $socialUser->getId());
Method rules
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function rules()
{
$rules = [
'first_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
'last_name' => ['required', 'string', 'max:255', new NoHtmlTags()],
Method rules
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function rules()
{
$rules = [
'first_name' => [$this->requiredIfPut(), 'string', 'max:255', new NoHtmlTags()],
'last_name' => [$this->requiredIfPut(), 'string', 'max:255', new NoHtmlTags()],
Method register
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register(RegisterRequest $request): JsonResponse
{
$mustBeEnabledByAdmin = Config::get(
EscolaLmsAuthServiceProvider::CONFIG_KEY . '.account_must_be_enabled_by_admin', SettingStatusEnum::DISABLED
);
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(bool $firstName = false, bool $lastName = false, bool $age = false, bool $gender = false, bool $country = false, bool $city = false, bool $street = false, bool $postcode = false)
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
string $firstName,
string $lastName,
bool $isActive,
array $roles,
?string $email = null,
Method searchAndPaginate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
CriteriaDto $criteriaDto,
?array $columns = [],
?array $with = [],
?array $appends = [],
?int $perPage = null,
Method searchAndPaginate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
CriteriaDto $criteriaDto,
?array $columns = [],
?array $with = [],
?array $appends = [],
?int $perPage = null,
Function instantiateFromRequest
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function instantiateFromRequest(Request $request, bool $tree = false): self
{
$criteria = new Collection();
if (
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function askUserPassword
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function askUserPassword(bool $required = false)
{
$default = $required ? Str::random() : '';
while (1) {
$password = $this->ask('Password', $default);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"