@@ -15,5 +15,5 @@ |
||
15 | 15 | * modified in cascade to the next function in the queue. |
16 | 16 | * @throws \Exception |
17 | 17 | */ |
18 | - public function filter( $method, $filterable ); |
|
18 | + public function filter($method, $filterable); |
|
19 | 19 | } |
20 | 20 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | class SpecialEntitiesToPlaceholdersForView extends AbstractHandler { |
16 | 16 | |
17 | - public function transform( $segment ) { |
|
17 | + public function transform($segment) { |
|
18 | 18 | |
19 | 19 | $segment = str_ireplace( |
20 | 20 | [ |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | class LtGtEncode extends AbstractHandler { |
8 | 8 | |
9 | - public function transform( $segment ) { |
|
9 | + public function transform($segment) { |
|
10 | 10 | // restore < e > |
11 | - $segment = str_replace( "<", "<", $segment ); |
|
12 | - $segment = str_replace( ">", ">", $segment ); |
|
11 | + $segment = str_replace("<", "<", $segment); |
|
12 | + $segment = str_replace(">", ">", $segment); |
|
13 | 13 | |
14 | 14 | return $segment; |
15 | 15 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | class EmojiToEntity extends AbstractHandler { |
16 | 16 | |
17 | - public function transform( $segment ) { |
|
18 | - return Emoji::toEntity( $segment ); |
|
17 | + public function transform($segment) { |
|
18 | + return Emoji::toEntity($segment); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -9,9 +9,9 @@ |
||
9 | 9 | /** |
10 | 10 | * @inheritDoc |
11 | 11 | */ |
12 | - public function transform( $segment ) { |
|
12 | + public function transform($segment) { |
|
13 | 13 | return str_replace( |
14 | - [ "\r\n", "\r", "\n", "\t" ], |
|
14 | + ["\r\n", "\r", "\n", "\t"], |
|
15 | 15 | [ |
16 | 16 | ' ', |
17 | 17 | ' ', |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | class EntityToEmoji extends AbstractHandler { |
16 | 16 | |
17 | - public function transform( $segment ) { |
|
18 | - return Emoji::toEmoji( $segment ); |
|
17 | + public function transform($segment) { |
|
18 | + return Emoji::toEmoji($segment); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 |
@@ -15,13 +15,13 @@ |
||
15 | 15 | |
16 | 16 | class RestoreXliffTagsContent extends AbstractHandler { |
17 | 17 | |
18 | - public function transform( $segment ) { |
|
18 | + public function transform($segment) { |
|
19 | 19 | |
20 | - $segment = preg_replace_callback( '/' . ConstantEnum::LTPLACEHOLDER . '(.*?)' . ConstantEnum::GTPLACEHOLDER . '/u', |
|
21 | - function ( $matches ) { |
|
22 | - $_match = base64_decode( $matches[ 1 ] ); |
|
20 | + $segment = preg_replace_callback('/'.ConstantEnum::LTPLACEHOLDER.'(.*?)'.ConstantEnum::GTPLACEHOLDER.'/u', |
|
21 | + function($matches) { |
|
22 | + $_match = base64_decode($matches[1]); |
|
23 | 23 | |
24 | - return ConstantEnum::LTPLACEHOLDER . $_match . ConstantEnum::GTPLACEHOLDER; |
|
24 | + return ConstantEnum::LTPLACEHOLDER.$_match.ConstantEnum::GTPLACEHOLDER; |
|
25 | 25 | }, |
26 | 26 | $segment |
27 | 27 | ); //base64 decode of the tag content to avoid unwanted manipulation |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | class CtrlCharsPlaceHoldToAscii extends AbstractHandler { |
9 | 9 | |
10 | - public function transform( $segment ) { |
|
10 | + public function transform($segment) { |
|
11 | 11 | |
12 | 12 | //Replace br placeholders |
13 | - $segment = str_replace( ConstantEnum::crlfPlaceholder, "\r\n", $segment ); |
|
14 | - $segment = str_replace( ConstantEnum::lfPlaceholder, "\n", $segment ); |
|
15 | - $segment = str_replace( ConstantEnum::crPlaceholder, "\r", $segment ); |
|
16 | - $segment = str_replace( ConstantEnum::tabPlaceholder, "\t", $segment ); |
|
13 | + $segment = str_replace(ConstantEnum::crlfPlaceholder, "\r\n", $segment); |
|
14 | + $segment = str_replace(ConstantEnum::lfPlaceholder, "\n", $segment); |
|
15 | + $segment = str_replace(ConstantEnum::crPlaceholder, "\r", $segment); |
|
16 | + $segment = str_replace(ConstantEnum::tabPlaceholder, "\t", $segment); |
|
17 | 17 | |
18 | 18 | return $segment; |
19 | 19 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param null $source |
37 | 37 | * @param null $target |
38 | 38 | */ |
39 | - public function __construct( $source = null, $target = null ) { |
|
39 | + public function __construct($source = null, $target = null) { |
|
40 | 40 | $this->source = $source; |
41 | 41 | $this->target = $target; |
42 | 42 | $this->notAllowedMap = $this->createNotAllowedMap(); |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | private function createNotAllowedMap() { |
49 | 49 | $map = []; |
50 | 50 | |
51 | - $all = include __DIR__ . "/language/all/not_allowed.php"; |
|
52 | - $map = array_merge( $map, $all ); |
|
51 | + $all = include __DIR__."/language/all/not_allowed.php"; |
|
52 | + $map = array_merge($map, $all); |
|
53 | 53 | |
54 | - if ( $this->source and file_exists( __DIR__ . "/language/" . $this->source . "/not_allowed.php" ) ) { |
|
55 | - $source = include __DIR__ . "/language/" . $this->source . "/not_allowed.php"; |
|
56 | - $map = array_merge( $map, $source ); |
|
54 | + if ($this->source and file_exists(__DIR__."/language/".$this->source."/not_allowed.php")) { |
|
55 | + $source = include __DIR__."/language/".$this->source."/not_allowed.php"; |
|
56 | + $map = array_merge($map, $source); |
|
57 | 57 | } |
58 | 58 | |
59 | - if ( $this->target and file_exists( __DIR__ . "/language/" . $this->target . "/not_allowed.php" ) ) { |
|
60 | - $target = include __DIR__ . "/language/" . $this->target . "/not_allowed.php"; |
|
61 | - $map = array_merge( $map, $target ); |
|
59 | + if ($this->target and file_exists(__DIR__."/language/".$this->target."/not_allowed.php")) { |
|
60 | + $target = include __DIR__."/language/".$this->target."/not_allowed.php"; |
|
61 | + $map = array_merge($map, $target); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return $map; |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - public function lock( $segment ) { |
|
73 | - $replacementMap = $this->createReplacementMap( $segment ); |
|
72 | + public function lock($segment) { |
|
73 | + $replacementMap = $this->createReplacementMap($segment); |
|
74 | 74 | $this->replacementMap = $replacementMap; |
75 | 75 | |
76 | - return str_replace( array_keys( $replacementMap ), array_values( $replacementMap ), $segment ); |
|
76 | + return str_replace(array_keys($replacementMap), array_values($replacementMap), $segment); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public function unlock( $segment ) { |
|
84 | + public function unlock($segment) { |
|
85 | 85 | $replacementMap = $this->replacementMap; |
86 | 86 | |
87 | - return str_replace( array_values( $replacementMap ), array_keys( $replacementMap ), $segment ); |
|
87 | + return str_replace(array_values($replacementMap), array_keys($replacementMap), $segment); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return array |
96 | 96 | */ |
97 | - private function createReplacementMap( $segment ) { |
|
97 | + private function createReplacementMap($segment) { |
|
98 | 98 | $replacementMap = []; |
99 | 99 | |
100 | - foreach ( $this->notAllowedMap as $item => $details ) { |
|
100 | + foreach ($this->notAllowedMap as $item => $details) { |
|
101 | 101 | |
102 | - $type = $details[ 'type' ]; |
|
102 | + $type = $details['type']; |
|
103 | 103 | |
104 | - switch ( $type ) { |
|
104 | + switch ($type) { |
|
105 | 105 | case 'exact': |
106 | - $replacementMap[ $item ] = self::PRE_LOCK_TAG . $this->maskString( $item ) . self::POST_LOCK_TAG; |
|
106 | + $replacementMap[$item] = self::PRE_LOCK_TAG.$this->maskString($item).self::POST_LOCK_TAG; |
|
107 | 107 | break; |
108 | 108 | |
109 | 109 | case 'regex': |
110 | - preg_match_all( '/' . $item . '/', $segment, $matches ); |
|
110 | + preg_match_all('/'.$item.'/', $segment, $matches); |
|
111 | 111 | |
112 | - foreach ( $matches[ 0 ] as $match ) { |
|
113 | - $replacementMap[ $match ] = self::PRE_LOCK_TAG . $this->maskString( $match ) . self::POST_LOCK_TAG; |
|
112 | + foreach ($matches[0] as $match) { |
|
113 | + $replacementMap[$match] = self::PRE_LOCK_TAG.$this->maskString($match).self::POST_LOCK_TAG; |
|
114 | 114 | } |
115 | 115 | break; |
116 | 116 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - private function maskString( $string ) { |
|
128 | - return str_replace( [ '%', '-', '_' ], '', $string ); |
|
127 | + private function maskString($string) { |
|
128 | + return str_replace(['%', '-', '_'], '', $string); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | \ No newline at end of file |