Code Duplication    Length = 27-27 lines in 2 locations

src/SpriteProcessor/HorizontalSpriteProcessor.php 1 location

@@ 5-31 (lines=27) @@
2
3
namespace CSSPrites\SpriteProcessor;
4
5
class HorizontalSpriteProcessor extends AbstractSpriteProcessor
6
{
7
    public function process()
8
    {
9
        $totalW = $this->spaces;
10
        $totalH = 0;
11
        foreach ($this->images->get() as $image) {
12
            $totalW += $image->getWidth() + $this->spaces;
13
            $totalH = max($image->getHeight(), $totalH);
14
        }
15
        $totalH += $this->spaces * 2;
16
17
        $this->image = $this->imageProcessor->create($totalW, $totalH, $this->background);
18
19
        $pointerX = $this->spaces;
20
        foreach ($this->images->sort('biggest')->get() as $image) {
21
            $image->setX($pointerX)->setY($this->spaces);
22
23
            $img = $this->imageProcessor->load($image->getFilepath());
24
            $this->image->insert($img, $image->getX(), $image->getY());
25
26
            $pointerX += $image->getWidth() + $this->spaces;
27
        }
28
29
        return $this;
30
    }
31
}
32

src/SpriteProcessor/VerticalSpriteProcessor.php 1 location

@@ 5-31 (lines=27) @@
2
3
namespace CSSPrites\SpriteProcessor;
4
5
class VerticalSpriteProcessor extends AbstractSpriteProcessor
6
{
7
    public function process()
8
    {
9
        $totalW = 0;
10
        $totalH = $this->spaces;
11
        foreach ($this->images->get() as $image) {
12
            $totalW = max($image->getWidth(), $totalW);
13
            $totalH += $image->getHeight() + $this->spaces;
14
        }
15
        $totalW += $this->spaces * 2;
16
17
        $this->image = $this->imageProcessor->create($totalW, $totalH, $this->background);
18
19
        $pointerY = $this->spaces;
20
        foreach ($this->images->sort('biggest')->get() as $image) {
21
            $image->setX($this->spaces)->setY($pointerY);
22
23
            $img = $this->imageProcessor->load($image->getFilepath());
24
            $this->image->insert($img, $image->getX(), $image->getY());
25
26
            $pointerY += $image->getHeight() + $this->spaces;
27
        }
28
29
        return $this;
30
    }
31
}
32