/** * @param string $socialType * @param string $username * @return string */ public function getSocialUrl($socialType, $username) { if (!$socialType || !$username) { return '#'; } return $this->socialUrlFormatter->getSocialUrl($socialType, $username); }
/** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = array()) { foreach (static::$socialFields as $socialType => $fieldName) { if (!empty($data[$fieldName])) { $data[$fieldName] = $this->socialUrlFormatter->getSocialUsername($socialType, $data[$fieldName]); } } return parent::denormalize($data, $class, $format, $context); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Unknown social network type "type" */ public function testGetSocialUsernameNoSocial() { $formatter = new SocialUrlFormatter(array()); $formatter->getSocialUsername('type', 'me'); }