Skip to content

Commit 919c104

Browse files
committed
Add image candidate set type getter
1 parent ae45c2c commit 919c104

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Scrutinizer Code Quality][scrutinizer-image]][scrutinizer-url] [![Code Climate][codeclimate-image]][codeclimate-url] [![Clear architecture][clear-architecture-image]][clear-architecture-url]
44

5-
> PHP library for translating HTML responsive images to CSS (sort of ...)
5+
> PHP library for translating HTML5 responsive images to CSS background images (sort of ...)
66
77
## Documentation
88

src/Respimgcss/Application/Contract/ImageCandidateSetInterface.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@
4444
*/
4545
interface ImageCandidateSetInterface extends \Jkphl\Respimgcss\Domain\Contract\ImageCandidateSetInterface
4646
{
47+
/**
48+
* Return the image candidate set type
49+
*
50+
* @return string|null Image candidate set type
51+
*/
52+
public function getType(): string;
53+
4754
/**
4855
* Return all image candidates as an array
4956
*
50-
* @return array
57+
* @return array Image candidates
5158
*/
5259
public function toArray(): array;
5360
}

src/Respimgcss/Application/Model/ImageCandidateSet.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ImageCandidateSet extends \Jkphl\Respimgcss\Domain\Model\ImageCandidateSet
5353
*
5454
* @var string
5555
*/
56-
protected $type;
56+
protected $type = null;
5757
/**
5858
* Image candidate values
5959
*
@@ -115,10 +115,20 @@ public function offsetSet($offset, $value): void
115115
/**
116116
* Return all image candidates as an array
117117
*
118-
* @return array
118+
* @return array Image candidates
119119
*/
120120
public function toArray(): array
121121
{
122122
return $this->imageCandidates;
123123
}
124+
125+
/**
126+
* Return the image candidate set type
127+
*
128+
* @return string|null Image candidate set type
129+
*/
130+
public function getType(): string
131+
{
132+
return $this->type;
133+
}
124134
}

src/Respimgcss/Tests/Application/ImageCandidateSetTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
namespace Jkphl\Respimgcss\Tests\Application;
3838

3939
use Jkphl\Respimgcss\Application\Model\ImageCandidateSet;
40+
use Jkphl\Respimgcss\Domain\Contract\ImageCandidateInterface;
4041
use Jkphl\Respimgcss\Domain\Model\DensityImageCandidate;
4142
use Jkphl\Respimgcss\Domain\Model\WidthImageCandidate;
4243
use Jkphl\Respimgcss\Tests\AbstractTestBase;
@@ -59,6 +60,7 @@ public function testImageCandidateSetInconsistentType()
5960
{
6061
$imageCandidateSet = new ImageCandidateSet(new DensityImageCandidate('image.jpg', 1));
6162
$this->assertInstanceOf(ImageCandidateSet::class, $imageCandidateSet);
63+
$this->assertEquals(ImageCandidateInterface::TYPE_DENSITY, $imageCandidateSet->getType());
6264

6365
$imageCandidateSet[] = new DensityImageCandidate('image.jpg', 2);
6466
$imageCandidateSet[] = new DensityImageCandidate('image.jpg', 3);

0 commit comments

Comments
 (0)