Code Duplication    Length = 29-29 lines in 2 locations

TaskManager/src/Kreta/TaskManager/Infrastructure/Symfony/GraphQl/Query/Organization/OrganizationResolver.php 2 locations

@@ 46-74 (lines=29) @@
43
        return $this->bySlug($args['slug']);
44
    }
45
46
    private function byId($id)
47
    {
48
        try {
49
            $this->queryBus->handle(
50
                new OrganizationOfIdQuery(
51
                    $id,
52
                    $this->currentUser
53
                ),
54
                $result
55
            );
56
57
            return $result;
58
        } catch (OrganizationDoesNotExistException $exception) {
59
            throw new UserError(
60
                sprintf(
61
                    'Does no exist any organization with the given "%s" id',
62
                    $id
63
                )
64
            );
65
        } catch (UnauthorizedOrganizationActionException $exception) {
66
            throw new UserError(
67
                sprintf(
68
                    'The "%s" user does not allow to access the "%s" organization',
69
                    $this->currentUser,
70
                    $id
71
                )
72
            );
73
        }
74
    }
75
76
    public function bySlug($slug)
77
    {
@@ 76-104 (lines=29) @@
73
        }
74
    }
75
76
    public function bySlug($slug)
77
    {
78
        try {
79
            $this->queryBus->handle(
80
                new OrganizationOfSlugQuery(
81
                    $slug,
82
                    $this->currentUser
83
                ),
84
                $result
85
            );
86
87
            return $result;
88
        } catch (OrganizationDoesNotExistException $exception) {
89
            throw new UserError(
90
                sprintf(
91
                    'Does no exist any organization with the given "%s" slug',
92
                    $slug
93
                )
94
            );
95
        } catch (UnauthorizedOrganizationActionException $exception) {
96
            throw new UserError(
97
                sprintf(
98
                    'The "%s" user does not allow to access the "%s" organization',
99
                    $this->currentUser,
100
                    $slug
101
                )
102
            );
103
        }
104
    }
105
}
106