@@ -456,9 +456,9 @@ public function minify(array $minify = []) : void {
456456 }
457457
458458 /**
459- * Compile the property to a string
459+ * Compile the document to a string
460460 *
461- * @param array $options An array of compilation options
461+ * @param array $options An array indicating output options, this is merged with cssdoc::$output
462462 * @return void
463463 */
464464 public function compile (array $ options = []) : string {
@@ -467,25 +467,23 @@ public function compile(array $options = []) : string {
467467 }
468468
469469 /**
470- * Compile the document as an HTML string and save it to the specified location
470+ * Compile the document and save it to the specified location
471471 *
472- * @param array $options An array indicating output options, this is merged with htmldoc::$output
473- * @return string The compiled HTML
472+ * @param string|null $file The file location to save the document to, or null to just return the compiled code
473+ * @param array $options An array indicating output options, this is merged with cssdoc::$output
474+ * @return string|bool The compiled CSS, or false if the file could not be saved
474475 */
475476 public function save (string $ file = null , array $ options = []) {
476477 $ css = $ this ->compile ($ options );
477478
478- // send back as string
479- if (!$ file ) {
480- return $ css ;
481-
482479 // save file
483- } elseif ( \file_put_contents ($ file , $ css ) === false ) {
480+ if ( $ file && \file_put_contents ($ file , $ css ) === false ) {
484481 \trigger_error ('File could not be written ' , E_USER_WARNING );
485- } else {
486- return true ;
482+ return false ;
487483 }
488- return false ;
484+
485+ // send back as string
486+ return $ css ;
489487 }
490488
491489 public function collection (array $ rules ) {
0 commit comments