Colors\Color::setUserStyles PHP Method

setUserStyles() public method

public setUserStyles ( array $userStyles )
$userStyles array
    public function setUserStyles(array $userStyles)
    {
        foreach ($userStyles as $name => $styles) {
            if (!$this->isAValidStyleName($name)) {
                throw new InvalidStyleNameException("{$name} is not a valid style name");
            }
            if (in_array($name, (array) $styles)) {
                throw new RecursionInUserStylesException('User style cannot reference itself.');
            }
        }
        $this->userStyles = $userStyles;
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: ColorTest.php プロジェクト: aydancoskun/octobercms
 public function testGivenInvalidUserStyleNameShouldThrowAnException()
 {
     $color = new Color();
     try {
         $color->setUserStyles(array('foo-bar' => 'red'));
         $this->fail('must throw an InvalidArgumentException');
     } catch (InvalidStyleNameException $e) {
         assertInstanceOf('InvalidArgumentException', $e);
         assertSame('foo-bar is not a valid style name', $e->getMessage());
     }
 }
All Usage Examples Of Colors\Color::setUserStyles