@@ 1878-1895 (lines=18) @@ | ||
1875 | * @return Assert |
|
1876 | * @throws AssertionFailedException |
|
1877 | */ |
|
1878 | public function directory($message = null, $propertyPath = null) |
|
1879 | { |
|
1880 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1881 | { |
|
1882 | return $this; |
|
1883 | } |
|
1884 | $this->string($message, $propertyPath); |
|
1885 | if ( !is_dir($this->value) ) |
|
1886 | { |
|
1887 | $message = $message ?: $this->overrideError; |
|
1888 | $message = sprintf( |
|
1889 | $message ?: 'Path "%s" was expected to be a directory.', |
|
1890 | $this->stringify($this->value) |
|
1891 | ); |
|
1892 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_DIRECTORY, $propertyPath); |
|
1893 | } |
|
1894 | return $this; |
|
1895 | } |
|
1896 | ||
1897 | /** |
|
1898 | * Assert that the value is something readable |
|
@@ 1905-1922 (lines=18) @@ | ||
1902 | * @return Assert |
|
1903 | * @throws AssertionFailedException |
|
1904 | */ |
|
1905 | public function readable($message = null, $propertyPath = null) |
|
1906 | { |
|
1907 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1908 | { |
|
1909 | return $this; |
|
1910 | } |
|
1911 | $this->string($message, $propertyPath); |
|
1912 | if ( !is_readable($this->value) ) |
|
1913 | { |
|
1914 | $message = $message ?: $this->overrideError; |
|
1915 | $message = sprintf( |
|
1916 | $message ?: 'Path "%s" was expected to be readable.', |
|
1917 | $this->stringify($this->value) |
|
1918 | ); |
|
1919 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_READABLE, $propertyPath); |
|
1920 | } |
|
1921 | return $this; |
|
1922 | } |
|
1923 | ||
1924 | /** |
|
1925 | * Assert that the value is something writeable |
|
@@ 1932-1949 (lines=18) @@ | ||
1929 | * @return Assert |
|
1930 | * @throws AssertionFailedException |
|
1931 | */ |
|
1932 | public function writeable($message = null, $propertyPath = null) |
|
1933 | { |
|
1934 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
1935 | { |
|
1936 | return $this; |
|
1937 | } |
|
1938 | $this->string($message, $propertyPath); |
|
1939 | if ( !is_writeable($this->value) ) |
|
1940 | { |
|
1941 | $message = $message ?: $this->overrideError; |
|
1942 | $message = sprintf( |
|
1943 | $message ?: 'Path "%s" was expected to be writeable.', |
|
1944 | $this->stringify($this->value) |
|
1945 | ); |
|
1946 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_WRITEABLE, $propertyPath); |
|
1947 | } |
|
1948 | return $this; |
|
1949 | } |
|
1950 | ||
1951 | /** |
|
1952 | * Assert that value is an email adress (using |
|
@@ 2093-2114 (lines=22) @@ | ||
2090 | * @return Assert |
|
2091 | * @throws AssertionFailedException |
|
2092 | */ |
|
2093 | public function alnum($message = null, $propertyPath = null) |
|
2094 | { |
|
2095 | if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) ) |
|
2096 | { |
|
2097 | return $this; |
|
2098 | } |
|
2099 | try |
|
2100 | { |
|
2101 | $this->regex('(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)', $message, $propertyPath); |
|
2102 | } |
|
2103 | catch (AssertionFailedException $e) |
|
2104 | { |
|
2105 | $message = $message ?: $this->overrideError; |
|
2106 | $message = sprintf( |
|
2107 | $message |
|
2108 | ?: 'Value "%s" is not alphanumeric, starting with letters and containing only letters and numbers.', |
|
2109 | $this->stringify($this->value) |
|
2110 | ); |
|
2111 | throw $this->createException($message, $this->overrideCode ?: self::INVALID_ALNUM, $propertyPath); |
|
2112 | } |
|
2113 | return $this; |
|
2114 | } |
|
2115 | ||
2116 | /** |
|
2117 | * Assert that the value is boolean True. |