Passed
Push — master ( 3295fe...37d5c2 )
by Richard
04:14 queued 14s
created

ConvertsRichtext::convertRichtext()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 5
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 8
rs 9.6111
1
<?php
2
3
4
namespace Riclep\Storyblok\Traits;
5
6
use Storyblok\RichtextRender\Resolver;
7
8
trait ConvertsRichtext
9
{
10
	protected $richtext = [];
11
12
	public function convertRichtext() {
13
		if ($this->richtext && count($this->richtext)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->richtext of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
14
15
			$richtextResolver = new Resolver();
16
17
			foreach ($this->richtext as $richtextField) {
18
				if ($this->content->has($richtextField)) {
19
					$this->content[$richtextField . '_html'] = $richtextResolver->render($this->content[$richtextField]);
0 ignored issues
show
Bug Best Practice introduced by
The property content does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
				}
21
			}
22
		}
23
	}
24
}