Completed
Push — master ( 096858...7ec34d )
by Gabriel
03:50
created

CanBootRecordsTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 46
ccs 14
cts 14
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A booted() 0 2 1
A bootIfNotBooted() 0 13 2
A boot() 0 3 1
A booting() 0 2 1
1
<?php
2
3
namespace Nip\Records\Traits\CanBoot;
4
5
/**
6
 * Trait CanBootRecordsTrait
7
 * @package Nip\Records\Traits\CanBoot
8
 */
9
trait CanBootRecordsTrait
10
{
11
    protected $booted = false;
12
13 31
    public function bootIfNotBooted()
14
    {
15 31
        if ($this->booted !== false) {
16 1
            return;
17
        }
18
//        $this->fireModelEvent('booting', false);
19
20 31
        $this->booting();
21 31
        $this->boot();
22 31
        $this->booted();
23
24
//        $this->fireModelEvent('booted', false);
25 31
        $this->booted = true;
26 31
    }
27
28
    /**
29
     * Perform any actions required before the model boots.
30
     *
31
     * @return void
32
     */
33 31
    protected function booting()
34
    {
35
        //
36 31
    }
37
38
    /**
39
     * Bootstrap the model and its traits.
40
     *
41
     * @return void
42
     */
43 31
    protected function boot()
44
    {
45 31
        $this->bootTraits();
0 ignored issues
show
Bug introduced by
It seems like bootTraits() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        $this->/** @scrutinizer ignore-call */ 
46
               bootTraits();
Loading history...
46 31
    }
47
48
    /**
49
     * Perform any actions required after the model boots.
50
     *
51
     * @return void
52
     */
53 31
    protected function booted()
54
    {
55
        //
56
    }
57
}