Code Duplication    Length = 16-21 lines in 4 locations

src/WebHemi/Data/Storage/AccessManagement/PolicyStorage.php 3 locations

@@ 92-107 (lines=16) @@
89
     *
90
     * @return bool|array<PolicyEntity>
91
     */
92
    public function getPoliciesByResourceId($resourceId)
93
    {
94
        $entityList = false;
95
        $dataList = $this->getDataAdapter()->getDataSet([$this->resourceId => $resourceId]);
96
97
        if (!empty($dataList)) {
98
            foreach ($dataList as $policy) {
99
                /** @var PolicyEntity $entity */
100
                $entity = $this->createEntity();
101
                $this->populateEntity($entity, $policy);
102
                $entityList[] = $entity;
103
            }
104
        }
105
106
        return $entityList;
107
    }
108
109
    /**
110
     * Returns a set of Policy entities identified by Application ID.
@@ 116-131 (lines=16) @@
113
     *
114
     * @return bool|array<PolicyEntity>
115
     */
116
    public function getPoliciesByApplicationId($applicationId)
117
    {
118
        $entityList = false;
119
        $dataList = $this->getDataAdapter()->getDataSet([$this->applicationId => $applicationId]);
120
121
        if (!empty($dataList)) {
122
            foreach ($dataList as $policy) {
123
                /** @var PolicyEntity $entity */
124
                $entity = $this->createEntity();
125
                $this->populateEntity($entity, $policy);
126
                $entityList[] = $entity;
127
            }
128
        }
129
130
        return $entityList;
131
    }
132
133
    /**
134
     * Returns a set of Policy entities identified by both Resource and Application IDs.
@@ 141-161 (lines=21) @@
138
     *
139
     * @return bool|array<PolicyEntity>
140
     */
141
    public function getPoliciesByResourceAndApplicationIds($resourceId, $applicationId)
142
    {
143
        $entityList = false;
144
        $dataList = $this->getDataAdapter()->getDataSet(
145
            [
146
                $this->resourceId => $resourceId,
147
                $this->applicationId => $applicationId
148
            ]
149
        );
150
151
        if (!empty($dataList)) {
152
            foreach ($dataList as $policy) {
153
                /** @var PolicyEntity $entity */
154
                $entity = $this->createEntity();
155
                $this->populateEntity($entity, $policy);
156
                $entityList[] = $entity;
157
            }
158
        }
159
160
        return $entityList;
161
    }
162
}
163

src/WebHemi/Data/Storage/User/UserMetaStorage.php 1 location

@@ 76-91 (lines=16) @@
73
     *
74
     * @return array<UserMetaEntity>
75
     */
76
    public function getUserMetaForUserId($userId)
77
    {
78
        $entityList = false;
79
        $dataList = $this->getDataAdapter()->getDataSet([$this->userId => $userId]);
80
81
        if (!empty($dataList)) {
82
            foreach ($dataList as $metaData) {
83
                /** @var UserMetaEntity $entity */
84
                $entity = $this->createEntity();
85
                $this->populateEntity($entity, $metaData);
86
                $entityList[] = $entity;
87
            }
88
        }
89
90
        return $entityList;
91
    }
92
}
93