Code Duplication    Length = 45-45 lines in 11 locations

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the CommonName Value Object
29
 */
30
class CommonNameType extends Type
31
{
32
    const NAME = 'stepup_common_name';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $commonName = new CommonName($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $commonName;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Location Value Object for the Configuration domain
29
 */
30
class ConfigurationContactInformationType extends Type
31
{
32
    const NAME = 'stepup_configuration_contact_information';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $contactInformation = new ContactInformation($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $contactInformation;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Institution Value Object for the Configuration domain
29
 */
30
class ConfigurationInstitutionType extends Type
31
{
32
    const NAME = 'stepup_configuration_institution';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $institution = new Institution($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $institution;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Location Value Object for the Configuration domain
29
 */
30
class ConfigurationLocationType extends Type
31
{
32
    const NAME = 'stepup_configuration_location';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $location = new Location($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $location;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Location Value Object
29
 */
30
class ContactInformationType extends Type
31
{
32
    const NAME = 'stepup_contact_information';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $contactInformation = new ContactInformation($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $contactInformation;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Email Value Object
29
 */
30
class EmailType extends Type
31
{
32
    const NAME = 'stepup_email';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $email = new Email($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $email;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Institution Value Object
29
 */
30
class InstitutionType extends Type
31
{
32
    const NAME = 'institution';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $institution = new Institution($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $institution;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Locale Value Object
29
 */
30
class LocaleType extends Type
31
{
32
    const NAME = 'stepup_locale';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $locale = new Locale($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $locale;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the Location Value Object
29
 */
30
class LocationType extends Type
31
{
32
    const NAME = 'stepup_location';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getClobTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $location = new Location($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $location;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the NameId Value Object
29
 */
30
class NameIdType extends Type
31
{
32
    const NAME = 'stepup_name_id';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $nameId = new NameId($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $nameId;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75

src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php 1 location

@@ 30-74 (lines=45) @@
27
/**
28
 * Custom Type for the RaLocationName Value Object
29
 */
30
class RaLocationNameType extends Type
31
{
32
    const NAME = 'stepup_ra_location_name';
33
34
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
35
    {
36
        return $platform->getVarcharTypeDeclarationSQL([]);
37
    }
38
39
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
40
    {
41
        if (is_null($value)) {
42
            return $value;
43
        }
44
45
        return (string) $value;
46
    }
47
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        if (is_null($value)) {
51
            return $value;
52
        }
53
54
        try {
55
            $raLocationName = new RaLocationName($value);
56
        } catch (InvalidArgumentException $e) {
57
            // get nice standard message, so we can throw it keeping the exception chain
58
            $doctrineExceptionMessage = ConversionException::conversionFailedFormat(
59
                $value,
60
                $this->getName(),
61
                $platform->getDateTimeFormatString()
62
            )->getMessage();
63
64
            throw new ConversionException($doctrineExceptionMessage, 0, $e);
65
        }
66
67
        return $raLocationName;
68
    }
69
70
    public function getName()
71
    {
72
        return self::NAME;
73
    }
74
}
75