Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
4 / 4
GoogleServiceFactory
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 make
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
1<?php
2
3namespace Qmp\Laravel\GoogleApiWrapper\Factory;
4
5use Exception;
6use Qmp\Laravel\GoogleApiWrapper\Client\GoogleClientWrapper;
7use Qmp\Laravel\GoogleApiWrapper\GoogleApiWrapper;
8
9class GoogleServiceFactory
10{
11    /**
12     * Undocumented variable
13     *
14     * @var string
15     */
16    const SERVICE_NAMESPACE = 'Qmp\\Laravel\\GoogleApiWrapper\\Services\\Google%sService';
17
18    /**
19     * Undocumented function
20     *
21     * @param string $service
22     * @param GoogleClientWrapper $client
23     * @param GoogleApiWrapper|null $apiWrapper
24     * @return GoogleBaseService|null
25     */
26    public static function make(string $service, GoogleClientWrapper $client, GoogleApiWrapper $apiWrapper = null)
27    {
28        $service = sprintf(self::SERVICE_NAMESPACE, ucfirst($service));
29
30        if (class_exists($service)) {
31            return $service::make($client, $apiWrapper);
32        }
33        
34        throw new Exception("Class $service not found !");
35    }
36}