GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

NoteableTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addNote() 0 13 1
1
<?php
2
3
namespace prgTW\BaseCRM\Service\Behavior;
4
5
use prgTW\BaseCRM\Service\Detached\Note;
6
use prgTW\BaseCRM\Service\Notes;
7
8
/**
9
 * @method Notes getNotes()
10
 */
11
trait NoteableTrait
12
{
13
	/**
14
	 * @param string $content
15
	 *
16
	 * @return Resource
0 ignored issues
show
Documentation introduced by
Should the return type not be \prgTW\BaseCRM\Resource\ResourceCollection|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
17
	 */
18
	public function addNote($content)
19
	{
20
		$note = new Note();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
21
		$note->content = $content;
0 ignored issues
show
Documentation introduced by
The property content does not exist on object<prgTW\BaseCRM\Service\Detached\Note>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
23
		/** @var Notes $notes */
24
		$notes  = $this->getNotes();
25
		$result = $notes->create($note, [
26
			'content',
27
		]);
28
29
		return $result;
30
	}
31
}
32