Skip to content

Commit

Permalink
Return normalized spot color name
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 17, 2024
1 parent 9cb9629 commit da97c2d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
6 changes: 5 additions & 1 deletion src/Spot.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ public function getSpotColorObj(string $name): Cmyk
*
* @param string $name Full name of the spot color.
* @param Cmyk $cmyk CMYK color object
*
* @return string Spot color key.
*/
public function addSpotColor(string $name, Cmyk $cmyk): void
public function addSpotColor(string $name, Cmyk $cmyk): string
{
$key = $this->normalizeSpotColorName($name);
$num = isset($this->spot_colors[$key]) ? $this->spot_colors[$key]['i'] : (count($this->spot_colors) + 1);
Expand All @@ -244,6 +246,8 @@ public function addSpotColor(string $name, Cmyk $cmyk): void
'name' => $name, // color name (key)
'color' => $cmyk, // CMYK color object
];

return $key;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion test/SpotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public function testAddSpotColor(): void
'alpha' => 0.65,
]
);
$spot->addSpotColor('test', $cmyk);
$key = $spot->addSpotColor('test', $cmyk);
$this->assertEquals('test', $key);

$res = $spot->getSpotColors();
$this->assertArrayHasKey('test', $res);
$this->assertEquals(1, $res['test']['i']);
Expand Down

0 comments on commit da97c2d

Please sign in to comment.