Completed
Push — development ( f93eb8...ffa1a0 )
by Thomas
20s
created

htdocs/src/Oc/Repository/AbstractEntity.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Oc\Repository;
4
5
/**
6
 * Class AbstractEntity
7
 */
8
abstract class AbstractEntity
9
{
10
    /**
11
     * Checks if the entity is new.
12
     *
13
     * @return bool
14
     */
15
    abstract public function isNew();
16
17
    /**
18
     * Sets all properties from array.
19
     *
20
     * @param array $data
21
     */
22 View Code Duplication
    public function fromArray(array $data)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        foreach ($data as $key => $value) {
25
            if (!property_exists($this, $key)) {
26
                continue;
27
            }
28
29
            $this->{$key} = $value;
30
        }
31
    }
32
33
    /**
34
     * Returns all properties as array.
35
     *
36
     * @return array
37
     */
38
    public function toArray()
39
    {
40
        return get_object_vars($this);
41
    }
42
}
43