Factory::create()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 3
1
<?php
2
3
namespace Richdynamix\PersonalisedProducts\Model\PredictionIO;
4
5
use \predictionio\EventClient;
6
use \predictionio\EngineClient;
7
8
/**
9
 * PredictionIO factory to return ready to use engine or event server objects
10
 *
11
 * @category  Richdynamix
12
 * @package   PersonalisedProducts
13
 * @author    Steven Richardson ([email protected]) @mage_gizmo
14
 */
15
class Factory
16
{
17
    /**
18
     * Factory create method for getting Event or Engine object
19
     *
20
     * @param $model
21
     * @param $entityUrl
22
     * @param null $accessKey
23
     * @return null|EngineClient|EventClient
24
     */
25
    public function create($model, $entityUrl, $accessKey = null)
26
    {
27
        if ('event' == $model) {
28
            return new EventClient($accessKey, $entityUrl);
29
        } elseif ('engine' == $model) {
30
            return new EngineClient($entityUrl);
31
        }
32
33
        return null;
34
    }
35
}
36