src/Charcoal/Source/StorableTrait.php
public function setKey($key)
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf(
                'Key must be a string; received %s',
                (is_object($key) ? get_class($key) : gettype($key))
            ));
        }

        if (!preg_match_all('/^[A-Za-z0-9_]+$/', $key)) {
            throw new InvalidArgumentException(
                sprintf('Key "%s" is invalid: must be alphanumeric / underscore.', $key)
            );
        }

        $this->key = $key;
        return $this;
    }
public function setKey($key)
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf(
                'Key must be a string; received %s',
                (is_object($key) ? get_class($key) : gettype($key))
            ));
        }

        if (!preg_match_all('/^[A-Za-z0-9_]+$/', $key)) {
            throw new InvalidArgumentException(
                sprintf('Key "%s" is invalid: must be alphanumeric / underscore.', $key)
            );
        }

        $this->key = $key;
        return $this;
    }
public function setKey ( $ key ) { if ( ! is_string ( $ key ) ) { throw new InvalidArgumentException ( sprintf ( 'Key must be a string; received %s' , ( is_object ( $ key ) ? get_class ( $ key ) : gettype ( $ key ) ) ) ) ; } if ( ! preg_match_all ( '/^[A-Za-z0-9_]+$/' , $ key ) ) { throw new InvalidArgumentException ( sprintf ( 'Key "%s" is invalid: must be alphanumeric / underscore.' , $ key ) ) ; } $ this -> key = $ key ; return $ this ; }
Set the primary property key.

For uniquely identifying this object in storage.

Note: For security reason, only alphanumeric characters (and underscores)
are valid key names. Although SQL can support more, there's really no reason to.

@param  string $key The object's primary key.
@throws InvalidArgumentException If the argument is not scalar.
@return self
Set the primary property key .