/** * Meta API for this type * * @param string $key Meta key to retrieve or empty to retrieve all. * * @return ObjectMeta|\Silk\Meta\Meta */ public function meta($key = '') { $meta = new ObjectMeta(static::OBJECT_TYPE, $this->id); if ($key) { return $meta->get($key); } return $meta; }
/** * @test */ public function it_can_get_a_dedicated_meta_object_for_a_given_key() { $post_id = $this->factory->post->create(); $postMeta = new ObjectMeta('post', $post_id); $this->assertInstanceOf(Meta::class, $postMeta->get('some_meta_key')); }