Passed
Push — master ( 3f8050...70788f )
by Luiz Kim
05:05 queued 02:57
created

Document   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 142
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 26
c 2
b 0
f 0
dl 0
loc 142
rs 10
wmc 11

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getDocumentType() 0 3 1
A getFile() 0 3 1
A getPeople() 0 3 1
A getDocument() 0 12 3
A setFile() 0 4 1
A setPeople() 0 4 1
A setDocumentType() 0 4 1
A setDocument() 0 4 1
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use ApiPlatform\Metadata\GetCollection;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ApiPlatform\Metadata\Get;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ApiPlatform\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use ApiPlatform\Metadata\ApiProperty;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiProperty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use ApiPlatform\Metadata\ApiFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Symfony\Component\Serializer\Annotation\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Annotation\Groups was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
/**
14
 * Document
15
 *
16
 * @ORM\EntityListeners ({App\Listener\LogListener::class})
17
 * @ORM\Table (name="document", uniqueConstraints={@ORM\UniqueConstraint (name="doc", columns={"document", "document_type_id"})}, indexes={@ORM\Index (name="type_2", columns={"document_type_id"}), @ORM\Index(name="file_id", columns={"file_id"}), @ORM\Index(name="type", columns={"people_id", "document_type_id"})})
18
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\DocumentRepository")
19
 */
20
#[ApiResource(operations: [new Get(security: 'is_granted(\'ROLE_CLIENT\')'), new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')')], formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], normalizationContext: ['groups' => ['document_read']], denormalizationContext: ['groups' => ['document_write']])]
21
#[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
22
class Document
23
{
24
    /**
25
     * @var integer
26
     *
27
     * @ORM\Column(name="id", type="integer", nullable=false)
28
     * @ORM\Id
29
     * @ORM\GeneratedValue(strategy="IDENTITY")
30
     */
31
    private $id;
32
    /**
33
     * @var integer
34
     *
35
     * @ORM\Column(name="document", type="bigint", nullable=false)
36
     * @Groups({"people_read", "document_read",  "carrier_read", "provider_read"})
37
     */
38
    private $document;
39
    /**
40
     * @var \ControleOnline\Entity\People
41
     *
42
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People", inversedBy="document")
43
     * @ORM\JoinColumns({
44
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id", nullable=false)
45
     * })
46
     * @Groups({"document_read"})
47
     */
48
    private $people;
49
    /**
50
     * @var \ControleOnline\Entity\File
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\File was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
     *
52
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\File")
53
     * @ORM\JoinColumns({
54
     *   @ORM\JoinColumn(name="file_id", referencedColumnName="id", nullable=true)
55
     * })
56
     */
57
    private $file;
58
    /**
59
     * @var \ControleOnline\Entity\DocumentType
60
     *
61
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\DocumentType")
62
     * @ORM\JoinColumns({
63
     *   @ORM\JoinColumn(name="document_type_id", referencedColumnName="id", nullable=false)
64
     * })
65
     * @Groups({"people_read", "document_read", "carrier_read"})
66
     */
67
    private $documentType;
68
    /**
69
     * Get id
70
     *
71
     * @return integer
72
     */
73
    public function getId()
74
    {
75
        return $this->id;
76
    }
77
    /**
78
     * Set document
79
     *
80
     * @param integer $document
81
     * @return Document
82
     */
83
    public function setDocument($document)
84
    {
85
        $this->document = $document;
86
        return $this;
87
    }
88
    /**
89
     * Get document
90
     *
91
     * @return integer
92
     */
93
    public function getDocument()
94
    {
95
        $document = (string) $this->document;
96
        // CPF
97
        if ($this->getDocumentType()->getDocumentType() == 'CPF') {
98
            return str_pad($document, 11, '0', STR_PAD_LEFT);
0 ignored issues
show
Bug Best Practice introduced by
The expression return str_pad($document...ne\Entity\STR_PAD_LEFT) returns the type string which is incompatible with the documented return type integer.
Loading history...
99
        }
100
        // CNPJ
101
        if ($this->getDocumentType()->getDocumentType() == 'CNPJ') {
102
            return str_pad($document, 14, '0', STR_PAD_LEFT);
0 ignored issues
show
Bug Best Practice introduced by
The expression return str_pad($document...ne\Entity\STR_PAD_LEFT) returns the type string which is incompatible with the documented return type integer.
Loading history...
103
        }
104
        return $this->document;
105
    }
106
    /**
107
     * Set file
108
     *
109
     * @param \ControleOnline\Entity\File $file
110
     * @return People
111
     */
112
    public function setFile(\ControleOnline\Entity\File $file = null)
113
    {
114
        $this->file = $file;
115
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type ControleOnline\Entity\Document which is incompatible with the documented return type ControleOnline\Entity\People.
Loading history...
116
    }
117
    /**
118
     * Get file
119
     *
120
     * @return \ControleOnline\Entity\File
121
     */
122
    public function getFile()
123
    {
124
        return $this->file;
125
    }
126
    /**
127
     * Set people
128
     *     
129
     * @return Document
130
     */
131
    public function setPeople($people)
132
    {
133
        $this->people = $people;
134
        return $this;
135
    }
136
    /**
137
     * Get people          
138
     */
139
    public function getPeople()
140
    {
141
        return $this->people;
142
    }
143
    /**
144
     * Set documentType
145
     *
146
     * @param \ControleOnline\Entity\DocumentType $documentType
147
     * @return Document
148
     */
149
    public function setDocumentType(\ControleOnline\Entity\DocumentType $documentType = null)
150
    {
151
        $this->documentType = $documentType;
152
        return $this;
153
    }
154
    /**
155
     * Get documentType
156
     *
157
     * @return \ControleOnline\Entity\DocumentType
158
     */
159
    public function getDocumentType()
160
    {
161
        return $this->documentType;
162
    }
163
}
164