public function setBorder(
        int $topWidth,
        $rightWidth = null,
        $bottomWidth = null,
        $leftWidth = null,
        string $colour = null
    ) : self {
        if (!is_int($rightWidth)) {
            $colour = $rightWidth;
            $rightWidth = $bottomWidth = $leftWidth = $topWidth;
        } elseif (!is_int($bottomWidth)) {
            $colour = $bottomWidth;
            $bottomWidth = $topWidth;
            $leftWidth = $rightWidth;
        } elseif (!is_int($leftWidth)) {
            $colour = $leftWidth;
            $leftWidth = $rightWidth;
        }

        $this->borderTopWidth = $topWidth;
        $this->borderRightWidth = $rightWidth;
        $this->borderBottomWidth = $bottomWidth;
        $this->borderLeftWidth = $leftWidth;

        if (is_string($colour)) {
            $this->setBorderColour($colour);
        } elseif ($colour !== null) {
            throw new \InvalidArgumentException('Invalid colour');
        }

        $this->calculateContentWidth();
        $this->generateBorderRows();
        $this->generatePaddingTopBottomRows();

        return $this;
    }
public function setBorder(
        int $topWidth,
        $rightWidth = null,
        $bottomWidth = null,
        $leftWidth = null,
        string $colour = null
    ) : self {
        if (!is_int($rightWidth)) {
            $colour = $rightWidth;
            $rightWidth = $bottomWidth = $leftWidth = $topWidth;
        } elseif (!is_int($bottomWidth)) {
            $colour = $bottomWidth;
            $bottomWidth = $topWidth;
            $leftWidth = $rightWidth;
        } elseif (!is_int($leftWidth)) {
            $colour = $leftWidth;
            $leftWidth = $rightWidth;
        }

        $this->borderTopWidth = $topWidth;
        $this->borderRightWidth = $rightWidth;
        $this->borderBottomWidth = $bottomWidth;
        $this->borderLeftWidth = $leftWidth;

        if (is_string($colour)) {
            $this->setBorderColour($colour);
        } elseif ($colour !== null) {
            throw new \InvalidArgumentException('Invalid colour');
        }

        $this->calculateContentWidth();
        $this->generateBorderRows();
        $this->generatePaddingTopBottomRows();

        return $this;
    }
public function setBorder ( int $ topWidth , $ rightWidth = null , $ bottomWidth = null , $ leftWidth = null , string $ colour = null ) : self { if ( ! is_int ( $ rightWidth ) ) { $ colour = $ rightWidth ; $ rightWidth = $ bottomWidth = $ leftWidth = $ topWidth ; } elseif ( ! is_int ( $ bottomWidth ) ) { $ colour = $ bottomWidth ; $ bottomWidth = $ topWidth ; $ leftWidth = $ rightWidth ; } elseif ( ! is_int ( $ leftWidth ) ) { $ colour = $ leftWidth ; $ leftWidth = $ rightWidth ; } $ this -> borderTopWidth = $ topWidth ; $ this -> borderRightWidth = $ rightWidth ; $ this -> borderBottomWidth = $ bottomWidth ; $ this -> borderLeftWidth = $ leftWidth ; if ( is_string ( $ colour ) ) { $ this -> setBorderColour ( $ colour ) ; } elseif ( $ colour !== null ) { throw new \ InvalidArgumentException ( 'Invalid colour' ) ; } $ this -> calculateContentWidth ( ) ; $ this -> generateBorderRows ( ) ; $ this -> generatePaddingTopBottomRows ( ) ; return $ this ; }
Shorthand function to set all borders values at once
Shorthand function to set all borders values at once