CakePdf\Pdf\CakePdf::margin PHP Метод

margin() публичный Метод

Several options are available Array format ------------ First param can be an array with the following options: - bottom - left - right - top Set margin for all borders -------------------------- $bottom is set to a string Leave all other parameters empty Set margin for horizontal and vertical -------------------------------------- $bottom value will be set to bottom and top $left value will be set to left and right
public margin ( null | string | array $bottom = null, null | string $left = null, null | string $right = null, null | string $top = null ) : mixed
$bottom null | string | array bottom margin, or array of margins
$left null | string left margin
$right null | string right margin
$top null | string top margin
Результат mixed
    public function margin($bottom = null, $left = null, $right = null, $top = null)
    {
        if ($bottom === null) {
            return ['bottom' => $this->_marginBottom, 'left' => $this->_marginLeft, 'right' => $this->_marginRight, 'top' => $this->_marginTop];
        }
        if (is_array($bottom)) {
            extract($bottom, EXTR_IF_EXISTS);
        }
        if ($bottom && $left === null && $right === null && $top === null) {
            $left = $right = $top = $bottom;
        }
        if ($bottom && $top === null) {
            $top = $bottom;
        }
        if ($left && $right === null) {
            $right = $left;
        }
        $this->marginBottom($bottom);
        $this->marginLeft($left);
        $this->marginRight($right);
        $this->marginTop($top);
        return $this;
    }

Usage Example

Пример #1
0
 /**
  *
  * @dataProvider provider
  */
 public function testMargin($config)
 {
     $pdf = new CakePdf($config);
     $pdf->margin(15, 20, 25, 30);
     $expected = ['bottom' => 15, 'left' => 20, 'right' => 25, 'top' => 30];
     $this->assertEquals($expected, $pdf->margin());
     $pdf = new CakePdf($config);
     $pdf->margin(75);
     $expected = ['bottom' => 75, 'left' => 75, 'right' => 75, 'top' => 75];
     $this->assertEquals($expected, $pdf->margin());
     $pdf = new CakePdf($config);
     $pdf->margin(20, 50);
     $expected = ['bottom' => 20, 'left' => 50, 'right' => 50, 'top' => 20];
     $this->assertEquals($expected, $pdf->margin());
     $pdf = new CakePdf($config);
     $pdf->margin(['left' => 120, 'right' => 30, 'top' => 34, 'bottom' => 15]);
     $expected = ['bottom' => 15, 'left' => 120, 'right' => 30, 'top' => 34];
     $this->assertEquals($expected, $pdf->margin());
     $pdf = new CakePdf($config);
     $expected = ['bottom' => 15, 'left' => 50, 'right' => 30, 'top' => 45];
     $this->assertEquals($expected, $pdf->margin());
 }
All Usage Examples Of CakePdf\Pdf\CakePdf::margin