Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — development ( aa3faf...1831fb )
by José
04:34
created

PostsController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 59
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 6 1
A show() 0 6 1
A store() 0 10 1
A update() 0 11 1
A destroy() 0 7 1
1
<?php
2
3
namespace DoeSangue\Http\Controllers\API;
4
5
use Illuminate\Http\Request;
6
use DoeSangue\Http\Requests\CreatePostRequest;
7
use DoeSangue\Http\Requests\UpdatePostRequest;
8
use DoeSangue\Http\Controllers\Controller;
9
use DoeSangue\Models\Post;
10
11
class PostsController extends Controller
12
{
13
14
    public function index()
15
    {
16
        $posts = Post::all();
17
18
        return response()->json(compact('posts'));
19
    }
20
21
    public function show($id)
22
    {
23
        $post = Post::find($id);
24
25
        return response()->json(compact('post'));
26
    }
27
28
    public function store(CreatePostRequest $request)
29
    {
30
        $post = new Post();
31
        $post->title = $request['title'];
0 ignored issues
show
Documentation introduced by
The property title does not exist on object<DoeSangue\Models\Post>. 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...
32
        $post->content = $request['content'];
0 ignored issues
show
Documentation introduced by
The property content does not exist on object<DoeSangue\Models\Post>. 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...
33
        $post->image = $request['image'];
0 ignored issues
show
Documentation introduced by
The property image does not exist on object<DoeSangue\Models\Post>. 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...
34
        $post->user_id = $request['user_id'];
0 ignored issues
show
Documentation introduced by
The property user_id does not exist on object<DoeSangue\Models\Post>. 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...
35
36
        return response()->json(compact('post'));
37
    }
38
39
    /**
40
     * Update Post by ID
41
     *
42
     * @method update
43
     *
44
     * @param  UpdatePostRequest $request
45
     * @param  integer $id
46
     *
47
     * @return boolean
48
     */
49
50
    public function update(UpdatePostRequest $request, $id)
51
    {
52
        $post = Campaign::find($id);
53
        $post->title = $request['title'];
54
        $post->title = $request['content'];
55
        $post->title = $request['image'];
56
        $post->title = $request['user_id'];
57
        $post->save();
58
59
        return response()->json(['message' => 'Post Updated']);
60
    }
61
62
    public function destroy($id)
63
    {
64
        $post = Post::findOrFail($id);
65
        $post->delete();
66
67
        return response()->json(['message' => 'Post delected']);
68
    }
69
}
70