-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathHashingModelInterface.php
137 lines (119 loc) · 2.76 KB
/
HashingModelInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
namespace Esensi\Model\Contracts;
use Illuminate\Contracts\Hashing\Hasher;
/**
* Hashing Model Interface.
*
*/
interface HashingModelInterface
{
/**
* Get the hashable attributes.
*
* @return array
*/
public function getHashable();
/**
* Set the hashable attributes.
*
* @param array $attributes to hash
*/
public function setHashable(array $attributes);
/**
* Add an attribute to the hashable array.
*
* @example addHashable( string $attribute, ... )
*
* @param string $attribute to purge
*/
public function addHashable($attribute);
/**
* Remove an attribute from the hashable array.
*
* @example addHashable( string $attribute, ... )
*
* @param string $attribute to purge
*/
public function removeHashable($attribute);
/**
* Merge an array of attributes with the hashable array.
*
* @param array $attributes to purge
*/
public function mergeHashable(array $attributes);
/**
* Returns whether or not the model will hash
* attributes before saving.
*
* @return bool
*/
public function getHashing();
/**
* Set whether or not the model will hash attributes
* before saving.
*
* @param bool
*/
public function setHashing($value);
/**
* Set the Hasher to use for hashing.
*
* @return Illuminate\Contracts\Hashing\Hasher
*/
public function getHasher();
/**
* Set the Hasher to use for hashing.
*
* @param Illuminate\Contracts\Hashing\Hasher $hasher
*/
public function setHasher(Hasher $hasher);
/**
* Returns whether the attribute is hashable.
*
* @param string $attribute name
*
* @return bool
*/
public function isHashable($attribute);
/**
* Returns whether the attribute is hashed.
*
* @param string $attribute name
*
* @return bool
*/
public function isHashed($attribute);
/**
* Hash attributes that should be hashed.
*/
public function hashAttributes();
/**
* Return a hashed string for the value.
*
* @param string $value
*
* @return string
*/
public function hash($value);
/**
* Return whether a plain value matches a hashed value.
*
* @param string $value
* @param string $hash to compare to
*
* @return bool
*/
public function checkHash($value, $hash);
/**
* Save with hashing even if hashing is disabled.
*
* @return bool
*/
public function saveWithHashing();
/**
* Save without hashing even if hashing is enabled.
*
* @return bool
*/
public function saveWithoutHashing();
}