1818 */
1919
2020/**
21- * Flat file adapter
21+ * Flat file adapter
2222 *
2323 * @author Dave Marshall <david.marshall@atstsolutions.co.uk
2424 */
2525class Flat implements AdapterInterface
2626{
2727 /**
28- * @string
28+ * @var string
2929 */
30- protected $ filename = null ;
30+ protected $ filename ;
3131
32- /**
33- * Construct
34- *
35- * @param string $filename
36- */
37- public function __construct ($ filename )
32+ public function __construct (string $ filename )
3833 {
3934 $ this ->filename = $ filename ;
4035 }
4136
4237 /**
43- * Get all migrated version numbers
44- *
45- * @return array
38+ * {@inheritdoc}
4639 */
4740 public function fetchAll ()
4841 {
@@ -52,16 +45,13 @@ public function fetchAll()
5245 }
5346
5447 /**
55- * Up
56- *
57- * @param Migration $migration
58- * @return AdapterInterface
48+ * {@inheritdoc}
5949 */
6050 public function up (Migration $ migration )
6151 {
6252 $ versions = $ this ->fetchAll ();
6353 if (in_array ($ migration ->getVersion (), $ versions )) {
64- return ;
54+ return $ this ;
6555 }
6656
6757 $ versions [] = $ migration ->getVersion ();
@@ -70,16 +60,13 @@ public function up(Migration $migration)
7060 }
7161
7262 /**
73- * Down
74- *
75- * @param Migration $migration
76- * @return AdapterInterface
63+ * {@inheritdoc}
7764 */
7865 public function down (Migration $ migration )
7966 {
8067 $ versions = $ this ->fetchAll ();
8168 if (!in_array ($ migration ->getVersion (), $ versions )) {
82- return ;
69+ return $ this ;
8370 }
8471
8572 unset($ versions [array_search ($ migration ->getVersion (), $ versions )]);
@@ -88,23 +75,19 @@ public function down(Migration $migration)
8875 }
8976
9077 /**
91- * Is the schema ready?
92- *
93- * @return bool
78+ * {@inheritdoc}
9479 */
9580 public function hasSchema ()
9681 {
9782 return file_exists ($ this ->filename );
9883 }
9984
10085 /**
101- * Create Schema
102- *
103- * @return AdapterInterface
86+ * {@inheritdoc}
10487 */
10588 public function createSchema ()
10689 {
107- if (!is_writeable (dirname ($ this ->filename ))) {
90+ if (!is_writable (dirname ($ this ->filename ))) {
10891 throw new \InvalidArgumentException (sprintf ('The file "%s" is not writeable ' , $ this ->filename ));
10992 }
11093
@@ -117,8 +100,10 @@ public function createSchema()
117100
118101 /**
119102 * Write to file
103+ *
104+ * @param array $versions
120105 */
121- protected function write ($ versions )
106+ protected function write (array $ versions )
122107 {
123108 if (false === file_put_contents ($ this ->filename , implode ("\n" , $ versions ))) {
124109 throw new \RuntimeException (sprintf ('The file "%s" could not be written to ' , $ this ->filename ));
0 commit comments