@@ 1902-1919 (lines=18) @@ | ||
1899 | * @return Assert |
|
1900 | * @throws AssertionFailedException |
|
1901 | */ |
|
1902 | public function directory($message = null, $propertyPath = null) |
|
1903 | { |
|
1904 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1905 | { |
|
1906 | return $this; |
|
1907 | } |
|
1908 | $this->string($message, $propertyPath); |
|
1909 | if ( !is_dir($this->value) ) |
|
1910 | { |
|
1911 | $message = $message ?: $this->overrideError; |
|
1912 | $message = sprintf( |
|
1913 | $message ?: 'Path "%s" was expected to be a directory.', |
|
1914 | $this->stringify($this->value) |
|
1915 | ); |
|
1916 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_DIRECTORY, $propertyPath); |
|
1917 | } |
|
1918 | return $this; |
|
1919 | } |
|
1920 | ||
1921 | /** |
|
1922 | * Assert that the value is something readable |
|
@@ 1929-1946 (lines=18) @@ | ||
1926 | * @return Assert |
|
1927 | * @throws AssertionFailedException |
|
1928 | */ |
|
1929 | public function readable($message = null, $propertyPath = null) |
|
1930 | { |
|
1931 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1932 | { |
|
1933 | return $this; |
|
1934 | } |
|
1935 | $this->string($message, $propertyPath); |
|
1936 | if ( !is_readable($this->value) ) |
|
1937 | { |
|
1938 | $message = $message ?: $this->overrideError; |
|
1939 | $message = sprintf( |
|
1940 | $message ?: 'Path "%s" was expected to be readable.', |
|
1941 | $this->stringify($this->value) |
|
1942 | ); |
|
1943 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_READABLE, $propertyPath); |
|
1944 | } |
|
1945 | return $this; |
|
1946 | } |
|
1947 | ||
1948 | /** |
|
1949 | * Assert that the value is something writeable |
|
@@ 1956-1973 (lines=18) @@ | ||
1953 | * @return Assert |
|
1954 | * @throws AssertionFailedException |
|
1955 | */ |
|
1956 | public function writeable($message = null, $propertyPath = null) |
|
1957 | { |
|
1958 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1959 | { |
|
1960 | return $this; |
|
1961 | } |
|
1962 | $this->string($message, $propertyPath); |
|
1963 | if ( !is_writeable($this->value) ) |
|
1964 | { |
|
1965 | $message = $message ?: $this->overrideError; |
|
1966 | $message = sprintf( |
|
1967 | $message ?: 'Path "%s" was expected to be writeable.', |
|
1968 | $this->stringify($this->value) |
|
1969 | ); |
|
1970 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_WRITEABLE, $propertyPath); |
|
1971 | } |
|
1972 | return $this; |
|
1973 | } |
|
1974 | ||
1975 | /** |
|
1976 | * Assert that value is an email adress (using |
|
@@ 2117-2138 (lines=22) @@ | ||
2114 | * @return Assert |
|
2115 | * @throws AssertionFailedException |
|
2116 | */ |
|
2117 | public function ausMobile($message = null, $propertyPath = null) |
|
2118 | { |
|
2119 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2120 | { |
|
2121 | return $this; |
|
2122 | } |
|
2123 | try |
|
2124 | { |
|
2125 | $this->regex('/^04[0-9]{8})$/', $message, $propertyPath); |
|
2126 | } |
|
2127 | catch ( AssertionFailedException $e ) |
|
2128 | { |
|
2129 | $message = $message ?: $this->overrideError; |
|
2130 | $message = sprintf( |
|
2131 | $message |
|
2132 | ?: 'Value "%s" is not an australian mobile number.', |
|
2133 | $this->stringify($this->value) |
|
2134 | ); |
|
2135 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_AUS_MOBILE, $propertyPath); |
|
2136 | } |
|
2137 | return $this; |
|
2138 | } |
|
2139 | ||
2140 | /** |
|
2141 | * Assert that value is alphanumeric. |
|
@@ 2148-2169 (lines=22) @@ | ||
2145 | * @return Assert |
|
2146 | * @throws AssertionFailedException |
|
2147 | */ |
|
2148 | public function alnum($message = null, $propertyPath = null) |
|
2149 | { |
|
2150 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2151 | { |
|
2152 | return $this; |
|
2153 | } |
|
2154 | try |
|
2155 | { |
|
2156 | $this->regex('(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)', $message, $propertyPath); |
|
2157 | } |
|
2158 | catch (AssertionFailedException $e) |
|
2159 | { |
|
2160 | $message = $message ?: $this->overrideError; |
|
2161 | $message = sprintf( |
|
2162 | $message |
|
2163 | ?: 'Value "%s" is not alphanumeric, starting with letters and containing only letters and numbers.', |
|
2164 | $this->stringify($this->value) |
|
2165 | ); |
|
2166 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_ALNUM, $propertyPath); |
|
2167 | } |
|
2168 | return $this; |
|
2169 | } |
|
2170 | ||
2171 | /** |
|
2172 | * Assert that the value is boolean True. |