src/Charcoal/Source/StorableTrait.php
public function setId($id)
    {
        if (!is_scalar($id)) {
            throw new InvalidArgumentException(sprintf(
                'ID for "%s" must be a scalar (integer, float, string, or boolean); received %s',
                get_class($this),
                (is_object($id) ? get_class($id) : gettype($id))
            ));
        }

        $key = $this->key();
        if ($key === 'id') {
            $this->id = $id;
        } else {
            $this[$key] = $id;
        }

        return $this;
    }
public function setId($id)
    {
        if (!is_scalar($id)) {
            throw new InvalidArgumentException(sprintf(
                'ID for "%s" must be a scalar (integer, float, string, or boolean); received %s',
                get_class($this),
                (is_object($id) ? get_class($id) : gettype($id))
            ));
        }

        $key = $this->key();
        if ($key === 'id') {
            $this->id = $id;
        } else {
            $this[$key] = $id;
        }

        return $this;
    }
public function setId ( $ id ) { if ( ! is_scalar ( $ id ) ) { throw new InvalidArgumentException ( sprintf ( 'ID for "%s" must be a scalar (integer, float, string, or boolean); received %s' , get_class ( $ this ) , ( is_object ( $ id ) ? get_class ( $ id ) : gettype ( $ id ) ) ) ) ; } $ key = $ this -> key ( ) ; if ( $ key === 'id' ) { $ this -> id = $ id ; } else { $ this [ $ key ] = $ id ; } return $ this ; }
Set the object's unique ID.

The actual property set depends on `key()`.

@param  mixed $id The object's ID.
@throws InvalidArgumentException If the argument is not scalar.
@return self
Set the object s unique ID .