AbstractRegression::calculate()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Regression;
4
5
use Carbon\Carbon;
6
7
/**
8
 * Class AbstractRegression
9
 *
10
 * @package Regression
11
 * @author  [email protected]
12
 */
13
abstract class AbstractRegression implements InterfaceRegression
14
{
15
16
    /**
17
     * @var array
18
     */
19
    protected $sourceSequence;
20
21
    /**
22
     * @var string
23
     */
24
    protected $equation;
25
26
    /**
27
     * @var array
28
     */
29
    protected $resultSequence;
30
31
    /**
32
     * @var RegressionModel
33
     */
34
    protected $regressionModel;
35
36
    /**
37
     * @var array
38
     */
39
    protected $sumIndex = [];
40
41
    /**
42
     * @var int
43
     */
44
    protected $dimension;
45
46
    abstract public function calculate();
47
48
    protected function push()
49
    {
50
        $this->regressionModel = new RegressionModel();
51
        $this->regressionModel->setEquation($this->equation);
52
        $this->regressionModel->setObjectId(\bin2hex(random_bytes(10)));
53
        $this->regressionModel->setResultSequence($this->resultSequence);
54
        $this->regressionModel->setSourceSequence($this->sourceSequence);
55
        $this->regressionModel->setCreateDate(Carbon::now()->toDateTimeString());
56
    }
57
58
    /**
59
     * @param array $data
60
     */
61
    public function setSourceSequence(array $data)
62
    {
63
        $this->sourceSequence = $data;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getEquation()
70
    {
71
        return $this->equation;
72
    }
73
74
    /**
75
     * @return RegressionModel
76
     */
77
    public function getRegressionModel()
78
    {
79
        return $this->regressionModel;
80
    }
81
82
    /**
83
     * @return array
84
     */
85
    public function getSourceSequence()
86
    {
87
        return $this->sourceSequence;
88
    }
89
}
90