Pop\Color\Space\Hex::get PHP Метод

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

Method to get the full RGB hex value
public get ( integer $type = Pop\Color\Color::STRING, boolean $hash = false, boolean $short = false ) : string
$type integer
$hash boolean
$short boolean
Результат string
    public function get($type = \Pop\Color\Color::STRING, $hash = false, $short = false)
    {
        $hex = null;
        switch ($type) {
            case 1:
                $hex = array('r' => $this->red, 'g' => $this->green, 'b' => $this->blue);
                break;
            case 2:
                $hex = array($this->red, $this->green, $this->blue);
                break;
            case 3:
                if ($short && null !== $this->shorthand) {
                    $hex = $hash ? '#' . $this->shorthand : $this->shorthand;
                } else {
                    $hex = $hash ? '#' . $this->hex : $this->hex;
                }
                break;
        }
        return $hex;
    }

Usage Example

Пример #1
0
 public function testGetHex()
 {
     $h = new Hex('#ee1c2d');
     $this->assertEquals('#ee1c2d', (string) $h);
     $this->assertTrue(is_array($h->get(Color::ASSOC_ARRAY)));
     $this->assertTrue(is_array($h->get(Color::NUM_ARRAY)));
     $this->assertEquals('#ee1c2d', $h->get(Color::STRING, true));
     $h = new Hex('#def');
     $this->assertEquals('def', $h->get(Color::STRING, false, true));
 }