Completed
Push — prototype ( 3bfdd7...aec713 )
by Peter
07:47
created

HeightStyleTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setHeight() 0 5 1
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoHtmlLib\Html;
12
13
/**
14
 * Trait HeightStyleTrait
15
 */
16
trait HeightStyleTrait
17
{
18
    /**
19
     * Set height style
20
     *
21
     * @param int $height Height in pixels
22
     * @param string $units
23
     * @return $this
24
     */
25
    public function setHeight($height, $units = 'px')
26
    {
27
        $this->setStyle(['height' => $height . $units]);
0 ignored issues
show
Bug introduced by
It seems like setStyle() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
28
        return $this;
29
    }
30
}
31