Failed Conditions
Push — master ( a46e0a...45361b )
by Maximo
03:09 queued 11s
created

CompaniesGroupsMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A mapToObject() 0 31 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Mapper;
6
7
use AutoMapperPlus\CustomMapper\CustomMapper;
8
use Canvas\Models\Subscription;
9
10
// You can either extend the CustomMapper, or just implement the MapperInterface
11
// directly.
12
class CompaniesGroupsMapper extends CustomMapper
13
{
14
    /**
15
     * @param Baka\Database\CustomFilters\CustomFilters $filter
0 ignored issues
show
Bug introduced by
There is no parameter named $filter. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
16
     * @param \Canvas\Dto\CustomFilter $filterSchema
0 ignored issues
show
Bug introduced by
There is no parameter named $filterSchema. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
17
     * @return ListSchema
18
     */
19
    public function mapToObject($companiesGroup, $companiesGroupDto, array $context = [])
20
    {
21
        $companiesGroupDto->id = $companiesGroup->getId();
22
        $companiesGroupDto->name = $companiesGroup->name;
23
        $companiesGroupDto->users_id = $companiesGroup->users_id;
24
        $companiesGroupDto->apps_id = $companiesGroup->apps_id;
25
        $companyArray = [];
26
        /**
27
         * Let's find all companies and their apps plans
28
         */
29
        foreach ($companiesGroup->getCompanies() as $company) {
30
31
            $subscription = Subscription::findFirst([
32
                'conditions'=> 'user_id = ?0 and companies_id = ?1 and is_deleted = 0',
33
                'bind'=>[$companiesGroup->users_id,$company->id]
34
            ]);
35
36
            foreach ($company as $key => $value) {
37
                $companyArray[$key] = $value;
38
                $companyArray['app_plan'] = $subscription->getAppPlan();
39
            }
40
41
            $companiesGroupDto->companies[] = $companyArray;
42
        }
43
        $companiesGroupDto->created_at = $companiesGroup->created_at;
44
        $companiesGroupDto->updated_at = $companiesGroup->updated_at;
45
        $companiesGroupDto->is_deleted = $companiesGroup->is_deleted;
46
47
48
        return $companiesGroupDto;
49
    }
50
}
51