SerializableTrait::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 5.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Majora\Framework\Serializer\Model;
4
5
@trigger_error('The '.__NAMESPACE__.'\SerializableTrait class is deprecated and will be removed in 2.0. Use Majora\Framework\Normalizer\Model\NormalizableTrait instead.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
6
7
use Majora\Framework\Normalizer\Model\NormalizableTrait;
8
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
9
10
/**
11
 * Implements a generic serializable trait.
12
 *
13
 * @see SerializableInterface
14
 * @see ScopableInterface
15
 * @deprecated
16
 *
17
 * @method getScopes()
18
 */
19
trait SerializableTrait
20
{
21
    use NormalizableTrait;
22
23
    /**
24
     * @see SerializableInterface::serialize()
25
     */
26 10
    public function serialize($scope = 'default', PropertyAccessorInterface $propertyAccessor = null)
0 ignored issues
show
Unused Code introduced by
The parameter $propertyAccessor is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28 10
        @trigger_error(sprintf('The method %s() is deprecated and will be removed in 2.0. Use Majora\Framework\Normalizer\Model\NormalizableTrait::normalize() instead.', __METHOD__), E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
29
30 10
        return $this->normalize($scope);
31
    }
32
33
    /**
34
     * @see SerializableInterface::deserialize()
35
     */
36 16
    public function deserialize(array $data, PropertyAccessorInterface $propertyAccessor = null)
0 ignored issues
show
Unused Code introduced by
The parameter $propertyAccessor is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
    {
38 16
        @trigger_error(sprintf('The method %s() is deprecated and will be removed in 2.0. Use Majora\Framework\Normalizer\Model\NormalizableTrait::denormalize() instead.', __METHOD__), E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
39
40 16
        return $this->denormalize($data);
41
    }
42
}
43