Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.64% covered (warning)
63.64%
7 / 11
60.00% covered (warning)
60.00%
3 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
Emprestimo
63.64% covered (warning)
63.64%
7 / 11
60.00% covered (warning)
60.00%
3 / 5
6.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 ativar
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 inativar
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getAtivo
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Core\Models;
4
5class Emprestimo
6{
7    protected bool $ativo;
8
9    public \DateTimeImmutable   $created_at;
10    public \DateTime            $updated_at;
11
12    public \DateTimeImmutable   $dataEntregaPrevista;
13    public ?\DateTimeImmutable  $dataEntregaRealizada = null;
14
15    public function __construct(
16        private     ?int                $id = null,
17        public      Livro               $livro,
18        public      Usuario             $usuarioMembro,
19        public      Usuario             $usuarioColaborador,
20        public     \DateTimeImmutable   $dataEmprestimo,
21    ) {
22        $dataEntregaPrevista = \DateTime::createFromImmutable($this->dataEmprestimo);
23        $dataEntregaPrevista->modify('2 weeks');
24
25        $this->dataEntregaPrevista = \DateTimeImmutable::createFromMutable(
26            $dataEntregaPrevista
27        );
28
29        $this->ativo = true;
30    }
31
32    public function getId() {
33        return $this->id;
34    }
35
36    public function ativar() {
37        $this->ativo = true;
38        return $this;
39    }
40
41    public function inativar() {
42        $this->ativo = false;
43        return $this;
44    }
45
46    public function getAtivo() {
47        return $this->ativo;
48    }
49}
50