Code Duplication    Length = 15-16 lines in 3 locations

Controller/ApiController.php 3 locations

@@ 84-99 (lines=16) @@
81
     * @Method("GET")
82
     * @View()
83
     */
84
    public function discountAction(Request $request)
85
    {
86
        $em = $this->get('em');
87
        $query = $em->getRepository('Newscoop\PaywallBundle\Entity\Discount')
88
            ->findActive();
89
90
        $paginator = $this->get('newscoop.paginator.paginator_service');
91
        $discounts = $paginator->paginate(
92
            $query,
93
            array(
94
                'distinct' => false,
95
            )
96
        );
97
98
        return $discounts;
99
    }
100
101
    /**
102
     * @Route("/api/paywall/currencies.{_format}", defaults={"_format"="json"}, name="newscoop_gimme_paywall_currency")
@@ 107-121 (lines=15) @@
104
     * @Method("GET")
105
     * @View()
106
     */
107
    public function currencyAction(Request $request)
108
    {
109
        $currencyRepository = $this->get('newscoop_paywall.currency.repository');
110
        $query = $currencyRepository->findAllAvailable();
111
112
        $paginator = $this->get('newscoop.paginator.paginator_service');
113
        $currencies = $paginator->paginate(
114
            $query,
115
            array(
116
                'distinct' => false,
117
            )
118
        );
119
120
        return $currencies;
121
    }
122
123
    /**
124
     * @Route("/api/paywall/gateways.{_format}", defaults={"_format"="json"}, name="newscoop_gimme_paywall_gateways")
@@ 129-144 (lines=16) @@
126
     * @Method("GET")
127
     * @View()
128
     */
129
    public function gatewaysAction(Request $request)
130
    {
131
        $provider = $this->get('newscoop_paywall.method_provider');
132
        $query = $provider->getEnabledMethods();
133
        $paginator = $this->get('newscoop.paginator.paginator_service');
134
        $gateways = $paginator->paginate(
135
            $query,
136
            array(
137
                'distinct' => false,
138
            )
139
        );
140
141
        $gateways['items'][] = $provider->getDefaultMethod();
142
143
        return $gateways;
144
    }
145
}
146