Mail
[ ]
[ ]
[ ]
[ ]
[ ]
Source for file parser_options.php
Documentation is available at parser_options.php
1. <?php
2. /**
3. * File containing the ezcMailParserOption class
4. *
5. * @package Mail
6. * @version 1.4
7. * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
8. * @license http://ez.no/licenses/new_bsd New BSD License
9. */
10.
11. /**
12. * Class containing the basic options for the mail parser.
13. *
14. * Example of how to use the parser options:
15. * <code>
16. * $options = new ezcMailParserOptions();
17. * $options->mailClass = 'ezcMail';
18. *
19. * $parser = new ezcMailParser( $options );
20. * </code>
21. *
22. * @property int $mailClass
23. * Specifies a class descending from ezcMail which can be returned by the
24. * parser if you plan to use another class instead of ezcMail.
25. *
26. * @package Mail
27. * @version 1.4
28. */
29. class ezcMailParserOptions extends ezcBaseOptions
30. {
31. /**
32. * Constructs an object with the specified values.
33. *
34. * @throws ezcBasePropertyNotFoundException
35. * if $options contains a property not defined
36. * @throws ezcBaseValueException
37. * if $options contains a property with a value not allowed
38. * @param array(string=>mixed) $options
39. */
40. public function __construct( array $options = array() )
41. {
42. $this->mailClass = 'ezcMail'; // default value for mail class is 'ezcMail'
43.
44. parent::__construct( $options );
45. }
46.
47. /**
48. * Sets the option $propertyName to $propertyValue.
49. *
50. * @throws ezcBasePropertyNotFoundException
51. * if the property $propertyName is not defined
52. * @throws ezcBaseValueException
53. * if $propertyValue is not correct for the property $propertyName
54. * @throws ezcBaseInvalidParentClassException
55. * if the class name passed as replacement mailClass does not
56. * inherit from ezcMail.
57. * @param string $propertyName
58. * @param mixed $propertyValue
59. * @ignore
60. */
61. public function __set( $propertyName, $propertyValue )
62. {
63. switch ( $propertyName )
64. {
65. case 'mailClass':
66. if ( !is_string( $propertyValue ) )
67. {
68. throw new ezcBaseValueException( $propertyName, $propertyValue, 'string that contains a class name' );
69. }
70.
71. // Check if the passed classname actually implements the
72. // correct parent class. We have to do that with reflection
73. // here unfortunately
74. $parentClass = new ReflectionClass( 'ezcMail' );
75. $handlerClass = new ReflectionClass( $propertyValue );
76. if ( 'ezcMail' !== $propertyValue && !$handlerClass->isSubclassOf( $parentClass ) )
77. {
78. throw new ezcBaseInvalidParentClassException( 'ezcMail', $propertyValue );
79. }
80. $this->properties[$propertyName] = $propertyValue;
81. break;
82.
83. default:
84. throw new ezcBasePropertyNotFoundException( $propertyName );
85. }
86. }
87. }
88. ?>
Last updated: Mon, 17 Dec 2007