Skip to content

Commit

Permalink
follow PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
roliod committed Oct 18, 2018
1 parent 6371ece commit ba955d7
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 92 deletions.
118 changes: 59 additions & 59 deletions install.php
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
<?php

/**
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/

$installer = new Installer();
$installer->install();

Class Installer
class Installer
{
public $helper_to_path;
public $library_to_path;
public $helper_from_path;
public $library_form_path;
public $helper_to_path;
public $library_to_path;
public $helper_from_path;
public $library_form_path;

public function __construct()
{
$this->library_to_path = "application/libraries/asset.php";
$this->helper_to_path = "application/helpers/asset_helper.php";
$this->library_form_path = "vendor/roliod/codeigniter-asset-versioning/src/libraries/asset.php";
$this->helper_from_path = "vendor/roliod/codeigniter-asset-versioning/src/helpers/asset_helper.php";
}

public function install()
{
$this->copy_helper();
$this->copy_library();
}
public function __construct()
{
$this->library_to_path = "application/libraries/asset.php";
$this->helper_to_path = "application/helpers/asset_helper.php";
$this->library_form_path = "vendor/roliod/codeigniter-asset-versioning/src/libraries/asset.php";
$this->helper_from_path = "vendor/roliod/codeigniter-asset-versioning/src/helpers/asset_helper.php";
}

public function copy_helper()
{
if ($this->exists($this->helper_to_path)) {
return $this;
public function install()
{
$this->copy_helper();
$this->copy_library();
}

$this->copy_file($this->helper_from_path, $this->helper_to_path);
public function copy_helper()
{
if ($this->exists($this->helper_to_path)) {
return $this;
}

return $this;
}
$this->copy_file($this->helper_from_path, $this->helper_to_path);

public function copy_library()
{
if ($this->exists($this->library_to_path)) {
return $this;
return $this;
}

$this->copy_file($this->library_form_path, $this->library_to_path);
public function copy_library()
{
if ($this->exists($this->library_to_path)) {
return $this;
}

$this->copy_file($this->library_form_path, $this->library_to_path);

return $this;
}
return $this;
}

/**
* Check if file exists
*
* @param string $file path
* @return bool
*/
public function exists($path)
{
return (bool)file_exists($path);
}
/**
* Check if file exists
*
* @param string $file path
* @return bool
*/
public function exists($path)
{
return (bool) file_exists($path);
}

/**
* Recursive Copy
*
* @param string $src
* @param string $dst
*/
public function copy_file($from, $to)
{
copy($from, $to);
}
/**
* Recursive Copy
*
* @param string $src
* @param string $dst
*/
public function copy_file($from, $to)
{
copy($from, $to);
}
}
34 changes: 17 additions & 17 deletions src/helpers/asset_helper.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}

/**
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/

if (! function_exists('version_url')) {

function version_url($path = '')
{
$CI =& get_instance();
$CI->load->library('asset');
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/

return $CI->asset->version_url($path);
}
if (!function_exists('version_url')) {
function version_url($path = '')
{
$CI = &get_instance();
$CI->load->library('asset');

return $CI->asset->version_url($path);
}
}
32 changes: 16 additions & 16 deletions src/libraries/asset.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}

/**
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/

class asset extends CI_Model
{
public function version_url($path = '')
{
$base_url = $this->config->item('base_url');
$version = filemtime(FCPATH . $path);

public function version_url($path = '')
{
$base_url = $this->config->item('base_url');
$version = filemtime(FCPATH . $path);

return $base_url . '/' . $path . '?v=' . $version;
}

return $base_url . '/' . $path . '?v=' . $version;
}
}

0 comments on commit ba955d7

Please sign in to comment.